本文介绍了在gridview中找不到标签的控制权的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
protected void btnGvOrdSubmit_Click(对象发件人,EventArgs e)
{
foreach (GridViewRow行 in GridView1.Rows)
{
if (row.RowType == DataControlRowType.DataRow)
{
标签产品=(标签)row.FindControl( lblProduct);
Label ProductID =(Label)row.FindControl( lblProduct_Id);
标签价格=(标签)row.FindControl( Unit_Price) ;
TextBox Quanty =(TextBox)row.FindControl( txtQuantity);
标签总数=(标签)row.FindControl( lblTotal) ;
SqlConnection con = new SqlConnection(StrConnection);
con.Open();
SqlCommand cmd = new SqlCommand();
cmd.Connection = con;
cmd.CommandType = CommandType.Text;
cmd.CommandText =
插入Order_Table(Product_Id,Quantity,Total_Price)值(@产品,@ Quanty,@ Total_Price);
cmd.CommandType = System.Data.CommandType.Text;
cmd.Parameters.Add( @ Product,SqlDbType.Char, 20 , Product_Id)。Value = ProductID。文本;
cmd.Parameters.AddWithValue( @ Quanty,Quanty.Text);
cmd.Parameters.AddWithValue( @ Total_Price,Total.Text);
cmd.ExecuteNonQuery();
}
}
}
标签总数=(标签)row.FindControl( lblTotal);我b
在这里我证明我的总价值可以通过乘法自动生成
价格*数量
请帮助
和thanx in adv。解决方案
protected void btnGvOrdSubmit_Click(object sender, EventArgs e) { foreach (GridViewRow row in GridView1.Rows) { if (row.RowType == DataControlRowType.DataRow) { Label Product = (Label)row.FindControl("lblProduct"); Label ProductID = (Label)row.FindControl("lblProduct_Id"); Label price = (Label)row.FindControl("Unit_Price"); TextBox Quanty = (TextBox)row.FindControl("txtQuantity"); Label Total = (Label)row.FindControl("lblTotal"); SqlConnection con = new SqlConnection(StrConnection); con.Open(); SqlCommand cmd = new SqlCommand(); cmd.Connection = con; cmd.CommandType = CommandType.Text; cmd.CommandText = "insert into Order_Table(Product_Id,Quantity,Total_Price ) values(@Product,@Quanty,@Total_Price) "; cmd.CommandType = System.Data.CommandType.Text; cmd.Parameters.Add("@Product", SqlDbType.Char, 20, "Product_Id").Value = ProductID.Text; cmd.Parameters.AddWithValue("@Quanty", Quanty.Text); cmd.Parameters.AddWithValue("@Total_Price", Total.Text); cmd.ExecuteNonQuery(); } } }
Label Total = (Label)row.FindControl("lblTotal");
gridview not find control on total when i save my grid view data in dataBase
here i justify my total value auto generate on lable by multiply
price *Quantity
please help
and thanx in adv.解决方案
这篇关于在gridview中找不到标签的控制权的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!