c# - is there better ways to get gridview values? -


for gridview How can I get the value of a cell when I click on a button and sometimes on this button I can be embedded in a gridview line, maybe anywhere else on the page beyond the gridview. My stupid and simple way is to create control of Gridview columns by creating each column as a label type on the client side, so it has something on the server to get values ​​like this text,

label lblName = (label) gvName.Rows [gvName.RowIndex] .FindControl ("lblSomeContent")

This is fine when it's just a few columns, but what if ten If there are more than different columns, should I do this again and again? Is there a better way? I have every gridview Trying to loop through the lights, but there are always empty values, which I do not know why. What you can do You can make an example of the grid row / example, and then you can use the control: "post-text" itemprop = "text"

  GridViewRow gRow = gvName.Rows [gvName.RowIndex];   

and then use the control

  label lblName = (label) gRow.FindControl ("lblSomeContent");   

Other controls similar

  textbox text box = (text box) gRow.FindControl ("txtSomeContent");    

Comments

Popular posts from this blog

excel vba - How to delete Solver(SOLVER.XLAM) code -

github - Teamcity & Git - PR merge builds - anyway to get HEAD commit hash? -

ios - Replace text in UITextView run slowly -