2014年7月13日 星期日

[RESOLVED] Field value in gridview


Hi,


I use this code:


Dim RowIndex As Integer = Convert.ToInt32(e.CommandArgument)
TextBox4.Text = Convert.ToInt32(GridView1.DataKeys(RowIndex).Value)

but I want reach value of field whit name: "picid" and no index,


How i do?



You can define multiple datakeys in the gridview, refer following to access them:


http://www.aspdotnet-suresh.com/2012/06/get-multiple-datakeyname-values-from.html



Set GridView1 DataKeyNames = "picid"

Another way bind the the CommandArgument property


CommandArgument ='<%# Eval("picid") %>'

then get it by : 


TextBox4.Text = e.CommandArgument.ToString();









oned_gk


Another way bind the CommandArgument ='<% #Eval( "picid") %>' then get it by : TextBox4 .Text = e. CommandArgument.ToString() ;


Thanks a lot.


沒有留言:

張貼留言