按编辑时如何给GridView1 赋值
问题:按编辑时如何给GridView1 赋值?
按一下编辑按钮后,如何赋一个值给 TxtCar_add
protected void GridView1_RowEditing(object sender, GridViewEditEventArgs e)
{
GridView1.EditIndex = e.NewEditIndex;
Bind();
//这里如何写?
}
aspx页面:
<asp:TemplateField HeaderText="去向">
<EditItemTemplate>
<asp:TextBox ID="TxtCar_add" runat="server" ></asp:TextBox>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="Label2" runat="server" Text='<%# Bind("Car_add") %>'></asp:Label>
</ItemTemplate>
<ItemStyle Width="250px" />
<ControlStyle Width="250px" />
</asp:TemplateField>
[解决办法]
<asp:TemplateField HeaderText="去向"> <EditItemTemplate> <asp:TextBox ID="TxtCar_add" runat="server" [color=#FF0000]Text=' <%# Bind("Car_add") %>'[/color]> </asp:TextBox> </EditItemTemplate> <ItemTemplate> <asp:Label ID="Label2" runat="server" Text=' <%# Bind("Car_add") %>'> </asp:Label> </ItemTemplate> <ItemStyle Width="250px" /> <ControlStyle Width="250px" /> </asp:TemplateField>