在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
1.DataGrid 批量更新 在html的form中设置如下的DataGrid
<asp:DataGrid id="DataGrid1" style="Z-INDEX: 101; LEFT: 16px; POSITION: absolute; TOP: 32px" runat="server"
Width="912px" Height="136px" AutoGenerateColumns="False"> <Columns> <asp:TemplateColumn HeaderText="ID"> <ItemTemplate> <asp:Label id=Label1 runat="server" Text='<%# DataBinder.Eval(Container, "DataItem.id") %>'> </asp:Label> </ItemTemplate> </asp:TemplateColumn> <asp:TemplateColumn HeaderText="用户名"> <ItemTemplate> <asp:TextBox id=TextBox1 runat="server" Text='<%# DataBinder.Eval(Container, "DataItem.uname") %>'> </asp:TextBox> </ItemTemplate> </asp:TemplateColumn> <asp:TemplateColumn HeaderText="性别"> <ItemTemplate> <asp:TextBox runat="server" Text='<%# DataBinder.Eval(Container, "DataItem.sex") %>' ID="Textbox2"> </asp:TextBox> </ItemTemplate> </asp:TemplateColumn> <asp:TemplateColumn HeaderText="年龄"> <ItemTemplate> <asp:TextBox runat="server" Text='<%# DataBinder.Eval(Container, "DataItem.age") %>' ID="Textbox3"> </asp:TextBox> </ItemTemplate> </asp:TemplateColumn> <asp:TemplateColumn HeaderText="电话"> <ItemTemplate> <asp:TextBox runat="server" Text='<%# DataBinder.Eval(Container, "DataItem.tel") %>' ID="Textbox4"> </asp:TextBox> </ItemTemplate> </asp:TemplateColumn> <asp:TemplateColumn HeaderText="地址"> <ItemTemplate> <asp:TextBox runat="server" Text='<%# DataBinder.Eval(Container, "DataItem.addr") %>' ID="Textbox5"> </asp:TextBox> </ItemTemplate> </asp:TemplateColumn> </Columns> </asp:DataGrid> <asp:Button id="Button1" style="Z-INDEX: 102; LEFT: 80px; POSITION: absolute; TOP: 232px" runat="server" Text="批量更新"></asp:Button> 在cs文件中写如下代码
private void Page_Load(object sender, System.EventArgs e)
} 2.GridView 批量更新 在html的form中设置如下的GridView
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" Width="873px">
<Columns> <asp:TemplateField HeaderText="ID"> <ItemTemplate> <asp:Label ID="Label1" runat="server" Text='<%# Bind("id") %>'></asp:Label> </ItemTemplate> </asp:TemplateField> <asp:TemplateField HeaderText="用户名"> <ItemTemplate> <asp:TextBox ID="TextBox2" runat="server" Text='<%# Bind("uname") %>'></asp:TextBox> </ItemTemplate> </asp:TemplateField> <asp:TemplateField HeaderText="性别"> <ItemTemplate> <asp:TextBox ID="TextBox3" runat="server" Text='<%# Bind("sex") %>'></asp:TextBox> </ItemTemplate> </asp:TemplateField> <asp:TemplateField HeaderText="年龄"> <ItemTemplate> <asp:TextBox ID="TextBox4" runat="server" Text='<%# Bind("age") %>'></asp:TextBox> </ItemTemplate> </asp:TemplateField> <asp:TemplateField HeaderText="电话"> <ItemTemplate> <asp:TextBox ID="TextBox5" runat="server" Text='<%# Bind("tel") %>'></asp:TextBox> </ItemTemplate> </asp:TemplateField> <asp:TemplateField HeaderText="地址"> <ItemTemplate> <asp:TextBox ID="TextBox6" runat="server" Text='<%# Bind("addr") %>'></asp:TextBox> </ItemTemplate> </asp:TemplateField> </Columns> </asp:GridView> </div> <asp:Button ID="Button1" runat="server" Text="批量更新" OnClick="Button1_Click" /> 在cs文件中写如下代码
SqlConnection conn = new SqlConnection(ConfigurationManager.AppSettings["conn"]);
protected void Page_Load(object sender, EventArgs e) } |
请发表评论