datagird中嵌套dropdownlist,dropdownlist的当前值为选定值
在对顾客选择的车型做确认,我在datagrid中嵌套dropdownlist,dropdownlist数据源捆绑在车型表上,如何使dropdownlist的当前值为顾客选定的车型?
<asp:TemplateColumn HeaderText= "车型 ">
<ItemTemplate>
<asp:Label runat= "server " ID= "car_mode " Text= ' <%# DataBinder.Eval(Container, "DataItem.machine_notes ") %> '> </asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:DropDownList runat= "server " ID= "machine_notes " DataTextField= "machine_notes " DataValueField= "machine_id " AutoPostBack= "true " OnSelectedIndexChanged= "notes_SelectIndexChanged "> </asp:DropDownList>
</EditItemTemplate>
</asp:TemplateColumn>
------解决方案--------------------System.Data.DataRowView drv = (System.Data.DataRowView)e.Row.DataItem;
notes.Items.FindByValue(drv[ "machine_id "].ToString()).Selected = true;