我的工作在Asp.Net一个GridView。在最初一个页面加载,我的gridview的样子:
I am working on a GridView in Asp.Net. When initially a the Page Loads, my gridview look like:
当用户点击,编辑成一排,我使用编辑模板,以显示域在DropDownList中。但问题是,当DROPDOWNLIST变负载数据,也就失去了域的当前值。 即如果我想编辑第4行,这是当前设置为计算机的域正在得到改变为工商管理硕士这是ofcourse第一个元素返回的数据源。
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.
我想显示的当前值(计算机)中的DropDownList选定的值。但我无法得到域,正在编辑的价值。
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.
要解决的异常使用AppendDataBoundItems =真。
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>