<asp:TemplateColumn FooterText="AAA" HeaderText="AAA" >
<HeaderStyle HorizontalAlign="center"/>
<ItemStyle HorizontalAlign="center" />
<ItemTemplate>
<asp:DropDownList runat="server" ID="DropDownList1" >
<asp:ListItem Value="1">A</asp:ListItem>
<asp:ListItem Value="2">B</asp:ListItem>
<asp:ListItem Value="3">C</asp:ListItem>
<asp:ListItem Value="4">D</asp:ListItem>
</asp:DropDownList>
</ItemTemplate>
</asp:TemplateColumn>我选择B保存了, 再进来还是显示A,怎么让下拉框和我的字段AAA绑定
<HeaderStyle HorizontalAlign="center"/>
<ItemStyle HorizontalAlign="center" />
<ItemTemplate>
<asp:DropDownList runat="server" ID="DropDownList1" >
<asp:ListItem Value="1">A</asp:ListItem>
<asp:ListItem Value="2">B</asp:ListItem>
<asp:ListItem Value="3">C</asp:ListItem>
<asp:ListItem Value="4">D</asp:ListItem>
</asp:DropDownList>
</ItemTemplate>
</asp:TemplateColumn>我选择B保存了, 再进来还是显示A,怎么让下拉框和我的字段AAA绑定
{
if(e.Item.ItemType==ListItemType.EditItem)
{
DropDownList ddl=(DropDownList)e.Item.FindControl( "ddl");
}
}
可能你是绑定的时候赋值的问题
可以在后台的RowDataBound事件里,找到你要赋值的控件,给他赋值,注意绑定的先后顺序,不然没有效果的