JosephMerkey
New Member
I am new to ASP.NET.The problem is I have a DetailsView with New, Edit, Delete option. When user clicks Edit, there two fields, VendorName and VendorBUName will change to the dropdown lists. This is working so far, but I would like to filter them, so lets me explain what I like to do.Page1.aspx has this code in the DetailsView to display dropdownlist when users click Edit.\[code\]<asp:TemplateField HeaderText="VendorName"> <ItemTemplate> <asp:Label ID="VendorName" runat="Server" style="text-align:left; width:100%" Text='<%# Eval("VendorName")%>' Width="70%"/> </ItemTemplate> <InsertItemTemplate> <aspropDownList id="VendorName" datasourceid="VendorSqlDataSource" datatextfield="VendorName" DataValueField="VendorID" SelectedValue='http://stackoverflow.com/questions/12786555/<%# Bind("VendorID") %>' runat="server" AutoPostBack="true" /> </InsertItemTemplate> <EditItemTemplate> <aspropDownList id="VendorName" datasourceid="VendorSqlDataSource" datatextfield="VendorName" DataValueField="VendorID" SelectedValue='http://stackoverflow.com/questions/12786555/<%# Bind("VendorID") %>' runat="server" AutoPostBack="true" /> </EditItemTemplate> </asp:TemplateField> <asp:TemplateField HeaderText="Vendor BU"> <ItemTemplate> <asp:Label ID="VendorBUName" runat="Server" style="text-align:left; width:100%" Text='<%# Eval("VendorBUName")%>' Width="70%"/> </ItemTemplate> <InsertItemTemplate> <aspropDownList id="VendorBUName" datasourceid="VendorBUSqlDataSource" datatextfield="VendorBUName" DataValueField="VendorBUID" SelectedValue='http://stackoverflow.com/questions/12786555/<%# Bind("VendorBUID") %>' runat="server"/> </InsertItemTemplate> <EditItemTemplate> <aspropDownList id="VendorBUName" datasourceid="VendorBUSqlDataSource" datatextfield="VendorBUName" DataValueField="VendorBUID" SelectedValue='http://stackoverflow.com/questions/12786555/<%# Bind("VendorBUID") %>' runat="server"/> </EditItemTemplate> </asp:TemplateField>\[/code\]This code in the same Page1.aspx (bottom), which binds with the dropdown lists to list the items.\[code\]<asp:SqlDataSource runat="server" ID="VendorSqlDataSource" ConnectionString="<%$Connectionstrings:ConnectionString%>" SelectCommand="SELECT VendorID, VendorName from MDF_Vendor" /><asp:SqlDataSource runat="server" ID="VendorBUSqlDataSource" ConnectionString="<%$Connectionstrings:ConnectionString%>" SelectCommand="SELECT VendorBUID, VendorBUName from MDF_VendorBU" />\[/code\]So far, this is working, but the list is not filtered. What I like to do is when user click Edit LinkButtom, the VendorBUName query should filter by VendorID from the Dropdownlist "VendorName". When the user select VendorName, it will also refilter the dropdownlist of VendorBUName. The query for VendorBUName should be something like "SelectCommand="SELECT VendorBUID, VendorBUName from MDF_VendorBU Where VendorID = " + The_VendorName_DropDownList_SelectedValue, but I couldn't figure out how to do this. I read some thread about ControlParameter, but still couldn't figure out. Can someone please help? Thanks!