If you use the a data source controls you can use the Bind expression for the DropDownLists SelectedValue instead of Eval, make sure you have added a parameter for the update command in the SqlDataSource that will get the data from table A. Take a look at this
example:
When you press the edit button next to the row, the dropdown list for contact title will appear. If you change the value of the dropdown and press the update button, the value will be saved. The example above uses the Northwind database it you
want to test it. If you want to get the value from a control programmatically when you do an update,
”>you can take a look at this post for an example
Fredrik N
All-Star
29674 Points
5334 Posts
MVP
Re: Dropdown within gridview??
Sep 03, 2004 04:40 AM|LINK
<asp:GridView ID="GridView1" Runat="server" DataSourceID="SqlDataSource1" DataKeyNames="CustomerID" AutoGenerateColumns="False"> <asp:DropDownList ID="DropDownList1" Runat="server" DataSourceID="SqlDataSource2" DataTextField="ContactTitle" DataValueField="ContactTitle" SelectedValue=''> <asp:SqlDataSource ID="SqlDataSource2" Runat="server" SelectCommand="SELECT DISTINCT [ContactTitle] FROM [Customers]" ConnectionString=""> <asp:SqlDataSource ID="SqlDataSource1" Runat="server" SelectCommand="SELECT [CustomerID], [CompanyName], [ContactTitle] FROM [Customers]" ConnectionString="" UpdateCommand="UPDATE [Customers] SET [CompanyName] = @CompanyName, [ContactTitle] = @ContactTitle WHERE [CustomerID] = @original_CustomerID">When you press the edit button next to the row, the dropdown list for contact title will appear. If you change the value of the dropdown and press the update button, the value will be saved. The example above uses the Northwind database it you want to test it. If you want to get the value from a control programmatically when you do an update, ”>you can take a look at this post for an exampleMVP, ASPInsider, WCF RIA Services Insider
My Blog