gridviewasp-classiclinkbuttontemplatefield

Templatefield in gridview


how can i get the values stored in one column of the gridview? this is the code:

<asp:TemplateField HeaderText="Document Code" HeaderStyle-BackColor="#000099" HeaderStyle-Width="150px">
                    <ItemTemplate>
                        <asp:LinkButton runat="server" ID="doc_code" Text='<%# Eval("doc_code")%>' CommandArgument='<%#Eval("doc_id") %>'
                            OnCommand="editDocument" CausesValidation="false">
                            <span class='glyphicon glyphicon-remove'></span>          
                        </asp:LinkButton>
                    </ItemTemplate>
                </asp:TemplateField>

i always get a blank value from this column i dont know how to get its values. Please help. Thanks


Solution

  • Use Bind in place of Eval as shown in below solution.

     <asp:LinkButton runat="server" ID="doc_code" Text='<%# Bind("doc_code")%>' CommandArgument='<%# Bind("doc_id") %>' OnCommand="editDocument" CausesValidation="false">