I am working on a GridView in Asp.Net. When initially a the Page Loads, my gridview look like: alt text http://www.freeimagehosting.net/uploads/e45e5b66d4.jpg
When a user clicks, to edit a row, I am using edit templates to show 'Domain' in a DropDownList. But problem is , when the DropDownlist gets load with data, it lost the current value of the 'Domain'.
i.e If I want to edit 4th Row, its domain which is currently set to 'Computers' is getting changed to 'MBA' which is ofcourse the first element return by the DataSource. alt text http://www.freeimagehosting.net/uploads/7d3f6ba9a5.jpg
I want to display the current value ('computers') as the selected value in DropDownList. But I am unable to get the value of Domain, which is being edited.
to solve exception use AppendDataBoundItems="true".
<asp:DropDownList ID="ddlCategory" runat="server" SelectedValue='<%# Eval("Domain") %>' DataSourceID="datasource" DataTextField="text" DataValueField="value" AppendDataBoundItems="true"> <asp:ListItem Text="Select..." Value=""></asp:ListItem> </asp:DropDownList>