如何获取所选行的值 [英] how to get the value of the selected row
本文介绍了如何获取所选行的值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
嗨
我想从网页中的gridview获取行的值,我的网格有三个类型为tempeletfield的字段。
当我点击url字段时获取字符串中url的值。
解决方案
你可以找到Texbox并从中获取数据。
试试这个:
protected void Gridview1_SelectedIndexChanged( object sender,EventArgs e)
{
< span class =code-keyword> string s1 =((TextBox)Gridview1.SelectedRow.FindControl( TextBox1\" 中跨度>))文本;
string s2 =((TextBox)Gridview1.SelectedRow.FindControl( TextBox2\" 中跨度>))的文本。
string s3 =((TextBox)Gridview1.SelectedRow.FindControl( TextBox3\" 跨度>))的文本。
}
--Amit
请参阅..
http://forums.asp.net/p/1190105/2041616 .aspx [ ^ ]
http://msdn.microsoft。 com / en-us / library / system.web.ui.webcontrols.gridview.selectedrow.aspx [ ^ ]
http://www.dotnetfunda.com/articles/article442-how从gridview-using-aspnet.aspx 获取所选行的值[ ^ ]
添加gridview的DataKeyNames属性到列表中,可以通过以下代码检索特定行的以下值...
int index = int .Parse(e.CommandArgument.ToString());
string value = grdView.DataKeys [index] .Value.ToString()。Trim( );
hi
i want to get the value of the row from the gridview in my webpage , my grid has three fields whith type tempeletfield .
when i click on the url field get the value of the url in string .
解决方案
You can find the Texboxes and get the data from it.
Try this:
protected void Gridview1_SelectedIndexChanged(object sender, EventArgs e) { string s1 = ((TextBox)Gridview1.SelectedRow.FindControl("TextBox1")).Text; string s2 = ((TextBox)Gridview1.SelectedRow.FindControl("TextBox2")).Text; string s3 = ((TextBox)Gridview1.SelectedRow.FindControl("TextBox3")).Text; }
--Amit
See..
http://forums.asp.net/p/1190105/2041616.aspx[^]
http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.gridview.selectedrow.aspx[^]
http://www.dotnetfunda.com/articles/article442-how-to-get-the-values-of-selected-row-from-a-gridview-using-aspnet.aspx[^]
Add DataKeyNames property of gridview to the list and the following value of the particular row can be retrieved by the following code...
int index = int.Parse(e.CommandArgument.ToString()); string value = grdView.DataKeys[index].Value.ToString().Trim();
这篇关于如何获取所选行的值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文