how to get celll value from gridview

protected void CovidSelfDecleartionDeatils_RowCommand(object sender, GridViewCommandEventArgs e) { try { ShowallRecord(); if (e.CommandArgument != “”) { int Index = Convert.ToInt32(e.CommandArgument); if (e.CommandName==”Select”) { DataTable dt_main = new DataTable();

                dt_main = (DataTable)ViewState["ReportData"];
         
                GridViewRow clickedRow = CovidSelfDecleartionDeatils.Rows[Index];

                Session["Filepath"] = clickedRow.Cells[9].Text;
                //Session["Filepath"] = CovidSelfDecleartionDeatils.Rows[Index].FindControl("FilePath");
                Session["Filepath1"] = CovidSelfDecleartionDeatils.DataKeys[Index]["Filepath"].ToString();
                string filepath = Session["Filepath"].ToString();
                //DataGridViewSelectedRowCollection rows = dataGridView1.SelectedRows;
                //string val = (string)rows[2].Cells["Late_Time"].Value;
            }
            }
        
        }
        catch
        {

        }
    }


}

<asp:GridView ID=”CovidSelfDecleartionDeatils” runat=”server” DataKeyNames=”EmployeeCode” AutoGenerateColumns=”False” BackColor=”#333333″ CellPadding=”5″ CellSpacing=”3″ ForeColor=”Black” Width=”100%” Height=”300px” OnRowCommand=”CovidSelfDecleartionDeatils_RowCommand” >

                                     <%--   <asp:BoundField DataField="InitiateMPPId" HeaderText="InitiateMPPId" >
                                            <HeaderStyle HorizontalAlign="Center" />
                                        </asp:BoundField>--%>
                                    <asp:BoundField DataField="EmployeeCode" HeaderText="EmployeeCode" ItemStyle-HorizontalAlign="Left" Visible="false"
                                         HeaderStyle-HorizontalAlign="Left" ControlStyle-BorderStyle="None" ItemStyle-CssClass="per10" 
                                        HeaderStyle-CssClass="header-center">
                                  </asp:BoundField>
                                       <%-- <asp:BoundField DataField="EmployeeCode" HeaderText="EmployeeCode" ItemStyle-HorizontalAlign="Left" Visible="false"
                                         HeaderStyle-HorizontalAlign="Left" ControlStyle-BorderStyle="None" ItemStyle-CssClass="per10" 
                                        HeaderStyle-CssClass="header-center">
                                  </asp:BoundField>--%>
                                            <asp:BoundField DataField="EmpName" HeaderText="Employee"  ItemStyle-HorizontalAlign="Left" HeaderStyle-HorizontalAlign="Left" >
                                       
                                        </asp:BoundField>
                                        <asp:BoundField DataField="Decleartion_Date" HeaderText="Date Decleartion"  ItemStyle-HorizontalAlign="Left" HeaderStyle-HorizontalAlign="Left" DataFormatString="{0:dd-MM-yyyy}" >
                                       
                                        </asp:BoundField>
                                         <asp:BoundField DataField="Ferver" HeaderText="Ferver"   ItemStyle-HorizontalAlign="Left" HeaderStyle-HorizontalAlign="Left" />
                                        <asp:BoundField DataField="Cough" HeaderText="Cough"   ItemStyle-HorizontalAlign="Left" HeaderStyle-HorizontalAlign="Left"/>
                                        <asp:BoundField DataField="Breathlessness" HeaderText="Breathlessness"  ItemStyle-HorizontalAlign="Left" HeaderStyle-HorizontalAlign="Left"/>
                                         
                                       
                                        <asp:BoundField DataField="OtherDiseases" HeaderText="OtherDiseases" ItemStyle-HorizontalAlign="Left" HeaderStyle-HorizontalAlign="Left" ItemStyle-CssClass="per50" ItemStyle-Height="25" HeaderStyle-Height="25" HeaderStyle-CssClass="header-center" HeaderStyle-Wrap="true"/>
                                          <asp:BoundField DataField="FileName" HeaderText="FileName" ItemStyle-HorizontalAlign="Left" HeaderStyle-HorizontalAlign="Left" ItemStyle-CssClass="per50" ItemStyle-Height="25" HeaderStyle-Height="25" HeaderStyle-CssClass="header-center" HeaderStyle-Wrap="true" Visible="false" />
                                         <asp:BoundField DataField="DeclarationID" HeaderText="DeclarationID" ItemStyle-HorizontalAlign="Left" HeaderStyle-HorizontalAlign="Left" ItemStyle-CssClass="per50" ItemStyle-Height="25" HeaderStyle-Height="25" HeaderStyle-CssClass="header-center" HeaderStyle-Wrap="true" Visible="false" />
                                         <asp:BoundField DataField="FilePath" HeaderText="FilePathfordownload" ItemStyle-HorizontalAlign="Left" HeaderStyle-HorizontalAlign="Left" ItemStyle-CssClass="per50" ItemStyle-Height="25" HeaderStyle-Height="25" HeaderStyle-CssClass="header-center" HeaderStyle-Wrap="true" Visible="false" />
                                          <asp:BoundField DataField="ContactwithCovid" HeaderText="Incontact with covid patient Last(14) days" ItemStyle-HorizontalAlign="Left" HeaderStyle-HorizontalAlign="Left" ItemStyle-CssClass="per50" ItemStyle-Height="25" HeaderStyle-Height="25" HeaderStyle-Width="15%" HeaderStyle-CssClass="header-center" HeaderStyle-Wrap="true"/>
                                        
                                          <%--<asp:TemplateField HeaderText="Status" ItemStyle-HorizontalAlign="Center">
                                            <ItemTemplate>
                                                <asp:ImageButton ID="btn_delete_record"
                                                    Width="20px" Height="20px" runat="server" ImageUrl="~/Content/Images/NewIcons/PDF.png" />
                                            </ItemTemplate>
                                        </asp:TemplateField>--%>
                                         <asp:ButtonField CommandName="Select" ControlStyle-CssClass="button" ButtonType="Image" ImageUrl="~/Content/Images/NewIcons/PDF.png"
                                                 ItemStyle-Width="5px" HeaderText="Download Attachment" />
                                        
                                           <asp:BoundField DataField="City" HeaderText="City"  ItemStyle-HorizontalAlign="Left" HeaderStyle-HorizontalAlign="Left" />
                                           <asp:BoundField DataField="TravelDate" HeaderText="TravelDate"  ItemStyle-HorizontalAlign="Left" HeaderStyle-HorizontalAlign="Left" DataFormatString="{0:dd-MM-yyyy}" />
                                         <asp:BoundField DataField="StateName" HeaderText="StateName"  ItemStyle-HorizontalAlign="Left" HeaderStyle-HorizontalAlign="Left" />
                                      
                                    </Columns>
                                    <FooterStyle BackColor="#CCCCCC" />
                                    <HeaderStyle BackColor="#5e5d5d" Font-Bold="True" ForeColor="White" />
                                    <PagerStyle BackColor="#CCCCCC" ForeColor="Black" HorizontalAlign="Left" />
                                    <RowStyle BackColor="White" />
                                    <SelectedRowStyle BackColor="#000099" Font-Bold="True" ForeColor="White" />
                                    <SortedAscendingCellStyle BackColor="#F1F1F1" />
                                    <SortedAscendingHeaderStyle BackColor="Gray" />
                                    <SortedDescendingCellStyle BackColor="#CAC9C9" />
                                    <SortedDescendingHeaderStyle BackColor="#383838" />
                                </asp:GridView>

what wrong in my showing excetion ” Object reference is not set” when i am saving value in session

Answer

remove visible=false and define new css class like

.donotshow { display: none; }

and add it HeaderStyle-CssClass and ItemStyle-CssClass