On Jun 22, 2:30 pm, Milosz Skalecki [MCAD] <mily...@DONTLIKESPAMwp.pl>
wrote:
Hi there again,
It's working fine for me. Could you paste aspx code for gridview?
--
Milosz
"bba...@yahoo.com" wrote:
On Jun 22, 2:56 am, Milosz Skalecki [MCAD] <mily...@DONTLIKESPAMwp.pl>
wrote:
Autogenerated columns are not included in the Columns collection. You have to
handle RowDataBound event instead:
protected void GridView1_RowDataBound(object sender,
GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow ||
e.Row.RowType == DataControlRowType.Header ||
e.Row.RowType == DataControlRowType.Footer)
{
e.Row.Cells[1].Visible = false;
}
}
hope this helps
--
Milosz
"bba...@yahoo.com" wrote:
I have a GetData methd which is returning a table using
sqldataadapter. I bound that datasource with GridView but now I want
to invisible Gridview's first column but it gives me following error
although I have 5 columns in my datatable.
Index was out of range. Must be non-negative and less than the size of
the collection.
Parameter name: index
GridView1.DataSource = GetData();
GridView1.DataBind();
GridView1.Columns[1].Visible = false;
Thanks for help me in advance- Hide quoted text -
- Show quoted text -
Yes it works but I can't hide the name of the Column. Rows are not
showing any data but the column name is still there. So, the column
is still showing with empty rows- Hide quoted text -
- Show quoted text -
Thanks again. Here is my code
if (e.Row.RowType == DataControlRowType.DataRow )
if (Convert.ToInt32(e.Row.Cells[5].Text) >=24)
{
e.Row.Cells[0].CssClass = "sdgStatusRed";
e.Row.Cells[5].Visible = false;
e.Row.Cells[5].Width = 0;
}
else
{
if (Convert.ToInt32(e.Row.Cells[5].Text) >= 20)
{
e.Row.Cells[0].CssClass = "sdgStatusOrange";
e.Row.Cells[5].Visible = false;
e.Row.Cells[5].Width = 0;
//GridView1.Columns[5].Visible = false;
}