Advertisement
Advertisement
| 03.27.2008 at 06:50PM PDT, ID: 23276243 |
|
[x]
Attachment Details
|
||
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64: |
aspx page
...
<div style="margin-top: 12px;">
Select Category:
<asp:dropdownlist id="ddlCategories" runat="server" appenddatabounditems="True" autopostback="True"
datasourceid="itCategories" datatextfield="ShipName" datavaluefield="OrderID">
</asp:dropdownlist>
<asp:sqldatasource id="itCategories" runat="server" connectionstring="<%$ ConnectionStrings:Northwind.SQL %>"
selectcommand="SELECT [OrderID], [ShipName] FROM [Orders] ORDER By [ShipName]">
</asp:sqldatasource>
</div>
<div>
Select Product:
<asp:dropdownlist id="ddlProducts" runat="server" appenddatabounditems="True" autopostback="True"
datasourceid="itProducts" datatextfield="ShipRegion" datavaluefield="OrderID">
</asp:dropdownlist>
<asp:sqldatasource id="itProducts" runat="server" connectionstring="<%$ ConnectionStrings:Northwind.SQL %>"
selectcommand="SELECT [OrderID], [ShipRegion] FROM [Orders] ORDER BY [ShipRegion]">
</asp:sqldatasource>
</div>
<asp:Panel ID="pnlGridView" runat="server" Width="100%">
...
</asp:GridView>
<asp:sqldatasource id="itProducts1" runat="server" connectionstring="<%$ ConnectionStrings:Northwind.SQL %>"
selectcommand="SELECT [OrderID], [ShipRegion], [ShipName]
FROM [Orders]
WHERE [OrderID] = @OrderID ORDER BY [ShipName]">
<selectparameters>
<asp:controlparameter controlid="ddlProducts" name="OrderID" propertyname="SelectedValue" type="Int32" />
<asp:controlparameter controlid="ddlCategories" name="OrderID" propertyname="SelectedValue" type="Int32" />
</selectparameters>
</asp:sqldatasource>
aspx.cs page
...
private string GetGridViewRowDropDownListValue(GridViewRow row, string sControlName)
{
string sFieldValue = string.Empty;
DropDownList _ctl = (DropDownList)row.FindControl(sControlName);
if (_ctl == null)
{
throw new Exception("GetGridViewRowDropDownListValue: could not find " + sControlName + " control!");
}
sFieldValue = _ctl.SelectedValue;
return sFieldValue;
}
...
private string GetDropDownListFieldValue(string sControlName)
{
string sFieldValue = string.Empty;
DropDownList _ctl = (DropDownList)fvOrders.FindControl(sControlName);
if (_ctl == null)
{
throw new Exception("GetDropDownListFieldValue: could not find " + sControlName + " control!");
}
sFieldValue = _ctl.SelectedValue;
return sFieldValue;
}
|