Mayur
Mayur

Reputation: 79

How to get gridview column values which are visible false

In my grid-view i am setting template field and item template as visible false..

But when i am running lop in java-script it is skipping this column.

Please help

I did as below

    <asp:TemplateField>
                            <ItemTemplate>
                                <asp:Label runat="server" ID="lblWrdCd"  style="display:block" Text='<% #Eval("WrdCd") %>'></asp:Label>
                            </ItemTemplate>
                        </asp:TemplateField >
                        <asp:TemplateField>
                            <ItemTemplate>
                                <asp:Label runat="server" style="visibility:hidden" ID="lblWingcd" Text='<% #Eval("WingCd") %>'></asp:Label>
                            </ItemTemplate>
                        </asp:TemplateField>
                        <asp:TemplateField>
                            <ItemTemplate>
                                <asp:Label runat="server" style="visibility:hidden" ID="lblBedTypCd" Text='<% #Eval("BedTypCd") %>'></asp:Label>
                            </ItemTemplate>
                        </asp:TemplateField>

And in javascript as below

                      var table = document.getElementById("<%=gddetails.ClientID%>");
                      var Row = table.rows[1];
                      alert(Row.cells[1].innerText);
                      alert(Row.cells[2].innerText);
                      alert(Row.cells[3].innerText);

But still it is not working

Upvotes: 0

Views: 2028

Answers (1)

Vinoth Narayan
Vinoth Narayan

Reputation: 275

    <asp:Label ID="lblbookid" runat="server" Text='<%#Eval("BookId")%>' Visible="false"></asp:Label>

   <asp:HiddenField ID="hiddenid" runat="server" Value='<%#Eval("BookId")%>'   />

We can't access the visible=false in client-side ..but passing the value to the hiddenfield we can use....

Upvotes: 1

Related Questions