开发者

Getting BoundField Value in gridview row_command

开发者 https://www.devze.com 2023-02-24 06:51 出处:网络
I need to get the bound开发者_如何学JAVA field value of the selected column in gridview_rowcommand.

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

精彩评论

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