Get the cell value of a GridView row

后端 未结 8 1081
灰色年华
灰色年华 2021-01-01 18:23

I am using the GridView - AutoGenerateSelectButton = \"True\" to select the row in order to get the Column 1 cell value.

I have tried:

         


        
8条回答
  •  春和景丽
    2021-01-01 18:46

    I suggest you use a HiddenField inside template field use FindControl to find this field.

    ie:

    ASPX

                    
                        
                            
                        
                    
    

    Code behind

    protected void gvAttachments_RowDeleting(object sender, GridViewDeleteEventArgs e)
        {
            GridView gv1 = (GridView)sender;
            GridViewRow gvr1 = (GridViewRow)gv1.Rows[e.RowIndex];
    
            //get hidden field value and not directly from the GridviewRow, as that will be null or empty!
            HiddenField hf1 = (HiddenField)gvr1.FindControl("hfFname");
            if (hf1 != null)
            {
               ..
            }
        }
    

提交回复
热议问题