如何找到gridview行的id [英] how to find id of gridview row
本文介绍了如何找到gridview行的id的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何找到一行的id我在grideview中有一个下拉列表现在我想找到下拉列表中所选索引已更改的行ID
解决方案
< pre lang =c#> protected void dd1_selectedindexchanged( object sender,EventArgs e)
{
DropDownList DropDownList1 = sender as DropDownList;
GridViewRow row =(GridViewRow)DropDownList1.NamingContainer;
int rowIndex = row.RowIndex;
Label Label3 =(Label)GridView1.Rows [rowIndex] .FindControl( Label3 );
标签lbl_price =(标签)GridView1.Rows [rowIndex] .FindControl( lbl_price 跨度>);
Int32 price = Convert.ToInt32(lbl_price.Text);
Int32 quantity = Convert.ToInt32(DropDownList1.SelectedValue);
字符串 total =( Int32 .Parse(quantity.ToString())* 的Int32 跨度> .Parse(price.ToString()))的ToString();
Label3.Text = total.ToString();
sumtotal();
}
how can i find the id of a row i have a dropdown inside a grideview now i want to find that row id which dropdown's selected index changed
解决方案
protected void dd1_selectedindexchanged(object sender, EventArgs e) { DropDownList DropDownList1 = sender as DropDownList; GridViewRow row = (GridViewRow)DropDownList1.NamingContainer; int rowIndex = row.RowIndex; Label Label3= (Label)GridView1.Rows[rowIndex].FindControl("Label3"); Label lbl_price = (Label)GridView1.Rows[rowIndex].FindControl("lbl_price"); Int32 price = Convert.ToInt32(lbl_price.Text); Int32 quantity = Convert.ToInt32(DropDownList1.SelectedValue); String total = (Int32.Parse(quantity.ToString())* Int32.Parse(price.ToString())).ToString(); Label3.Text = total.ToString(); sumtotal(); }
这篇关于如何找到gridview行的id的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文