Reputation: 5297
<asp:GridView Width="700" ID="gridInboxMessage" runat="server" DataSourceID="LinqDataSource1">
<Columns>
<asp:BoundField DataField="Row" Visible="false" HeaderStyle-Width="10" HeaderText="row" ReadOnly="True" SortExpression="Row" />
<asp:BoundField DataField="Title" HeaderStyle-Width="10" HeaderText="Title" ReadOnly="True" SortExpression="Title" />
</Columns>
</asp:GridView>
row
is visible=false.
How can get the text of this> gridInboxMessage.Rows[index].Cells[0].Text
does not return value
If row
is visible=true then by gridInboxMessage.Rows[index].Cells[0].Text
I can get text.
Upvotes: 1
Views: 752
Reputation: 52241
You can't get the value of the column that you had set visible=false
, because it is not rendered on the client side and it will not be available on postback. You can use a hidden field and get the value from the hidden field
instead.
<asp:TemplateField>
<ItemTemplate>
<asp:HiddenField runat="server" ID="hdf" Value='<# Eval("Row")'>
</asp:HiddenField>
</asp:TemplateField>
</ItemTemplate>
</asp:TemplateField>
Upvotes: 3
Reputation: 765
once it is established whether the row of datagrid and visible for the text you can use this example.
This example is for c#
string myValue = string.Empty;
myValue = this.dataGridView1.CurrentRow.Cells[0].Value.ToString();
Upvotes: 0
Reputation: 1536
You can do it with setting display:none on that column. This is less code, only adding a css on the column you want invisible
<style type="text/css">
.hiddencol
{
display:none;
}
</style>
<asp:GridView Width="700" ID="gridInboxMessage" runat="server" DataSourceID="LinqDataSource1">
<columns>
<asp:boundfield datafield="ProductID" itemstyle-cssclass="hiddencol" />
<asp:boundfield datafield="Name" headertext="Product Name" />
<asp:boundfield datafield="ProductNumber" headertext="Product Number" />
</columns>
</asp:GridView>
Upvotes: 2