开发者

Getting BoundField Value in gridview row_command

I need to get the bound开发者_如何学JAVA field value of the selected column in gridview_rowcommand.

Any ideas?


it will be like...

GridViewRow row = (GridViewRow)(((LinkButton)e.CommandSource).NamingContainer);
row.Cells[0].Text


It should be something like this.

if (e.CommandName=="CommandName")
    {
        int index = Convert.ToInt32(e.CommandArgument);
        GridViewRow row = GridView1.Rows[index];
        string boundFieldText= row.Cells[0].Text;
    }


To take the value of the field from grid view, first set the datakeyname then in default.aspx.cs page write below code:

//this is for linkbutton onclick u can use button also
  ## Coding ## 

   protected void lnkDownload_Click(object sender, EventArgs e)
    {
         LinkButton lnkbtn = sender as LinkButton;
          GridViewRow gvrow = lnkbtn.NamingContainer as GridViewRow;
          string username= gvDetails.DataKeys[gvrow.RowIndex].Value.ToString();
    }
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜