I have this BoundField
in a GridView
<asp:BoundField DataField="ReportId" HeaderText="RId" Visible="false" />
But when I try to get text in that field, it returns empty.
protected void gvwReports_RowCommand(object sender, GridViewCommandEventArgs e)
{
if (e.CommandName == "ViewSchedule")
{
int index = Convert.ToInt32(e.CommandArgument);
GridViewRow row = gvwReports.Rows[index];
string s = row.Cells[0].Text;
}
}
but, it returns a correct value if I change BoundField's
.Visible
property to true
Visible="false"
doesn't just "hide" that field on the client, it doesn't even send the data down to the client. So it is impossible to get it back from the client. So instead of settingVisible="false"
, use aCssClass
that will hide it from view on the client, but the data will still be there. Then the data will be available again server-side on a postback. Just as COLD TOLD suggests, but without the typo :), and remember to set the visibility of the header. – Coagulant