gridview读取textbox为空值
<asp:TemplateFieldHeaderText="修改数量"><ItemTemplate>数量<asp:TextBoxID="tb_Xsum"runat="se...
<asp:TemplateField HeaderText="修改数量">
<ItemTemplate>
数量
<asp:TextBox ID="tb_Xsum" runat="server" Width="24px" Height="11px"></asp:TextBox>
<asp:Button ID="bt_cartX" runat="server" CommandArgument='<%# Eval("CartID") %>'
Height="19px" OnClick="bt_cartX_Click" Text="修改" Width="40px" />
</ItemTemplate>
button的check事件中的代码
for (int i = 0; i < this.gv_cartinfo.Rows.Count; i++)
{
TextBox xtb = (gv_cartinfo.Rows[i].FindControl("tb_Xsum")) as TextBox;
/ lb_ifsession.Text = xtb.Text.ToString();
} 展开
<ItemTemplate>
数量
<asp:TextBox ID="tb_Xsum" runat="server" Width="24px" Height="11px"></asp:TextBox>
<asp:Button ID="bt_cartX" runat="server" CommandArgument='<%# Eval("CartID") %>'
Height="19px" OnClick="bt_cartX_Click" Text="修改" Width="40px" />
</ItemTemplate>
button的check事件中的代码
for (int i = 0; i < this.gv_cartinfo.Rows.Count; i++)
{
TextBox xtb = (gv_cartinfo.Rows[i].FindControl("tb_Xsum")) as TextBox;
/ lb_ifsession.Text = xtb.Text.ToString();
} 展开
2个回答
展开全部
protected void Button2_Click(object sender, EventArgs e)//删除BUTTON
{
Button2.Attributes.Add("onClick", "javascript:return confirm('确定要删除么');");
SqlConnection con = DB.createConnec();
con.Open();
for (int i = 0; i <= GridView1.Rows.Count - 1; i++)//循环GRIDVIEW控件中所有行!
{
CheckBox check = (CheckBox)GridView1.Rows[i].FindControl("CheckBox1"); //CHECKBOX1是单选的!查找GRIDVIEW控件中的CHECKBOX1
if (check.Checked == true)//判断是否选中GRIDVIEW中的CHECKBOX
{
string sqlstr = "delete from vote2 where voteID='" + GridView1.DataKeys[i].Value + "'";//定义删除选中数据的字符串
SqlCommand cmd = new SqlCommand(sqlstr, con);
cmd.ExecuteNonQuery();
}
}
con.Close();
bindData();
}
类似的!你可以看看
{
Button2.Attributes.Add("onClick", "javascript:return confirm('确定要删除么');");
SqlConnection con = DB.createConnec();
con.Open();
for (int i = 0; i <= GridView1.Rows.Count - 1; i++)//循环GRIDVIEW控件中所有行!
{
CheckBox check = (CheckBox)GridView1.Rows[i].FindControl("CheckBox1"); //CHECKBOX1是单选的!查找GRIDVIEW控件中的CHECKBOX1
if (check.Checked == true)//判断是否选中GRIDVIEW中的CHECKBOX
{
string sqlstr = "delete from vote2 where voteID='" + GridView1.DataKeys[i].Value + "'";//定义删除选中数据的字符串
SqlCommand cmd = new SqlCommand(sqlstr, con);
cmd.ExecuteNonQuery();
}
}
con.Close();
bindData();
}
类似的!你可以看看
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询