Hi There!
I am assigning a dataset at runtime to a webgrid's datasource (in designer the datasource is blank).
Me.WebDataGrid1.DataSource = DSMe.WebDataGrid1.DataMember = "orders"Me.WebDataGrid1.DataBind()
Grid shows correctly, no problem.
Now I want to hide two columns, but the me.Webdatagrid.Columns.Count is always 0. I tried with AutoGenerateColums set to True, set to False no way to get the columns in the collection. The .rows.count property shows the exact numbers of rows,
So I can't hide a columns because
Me.WebDataGrid1.Columns.FromKey("GUID").Hidden = True
returns an error becaus the columns could'nt be founded.
Any idea?
Hi,
You need to add the bound datafields to the columns collection. The example:
WebDataGrid1.AutoGenerateColumns = false; BoundDataField boundFld1 = new BoundDataField(true); boundFld1.Key = "ID"; boundFld1.Header.Text = "ID"; boundFld1.DataFieldName = "ID"; WebDataGrid1.Columns.Add(boundFld1); WebDataGrid1.Columns[“ID”].Hidden = true;
I’ve attached a sample of this which also includes Paging.
Please let me know if this resolves your issue.
Thanks,Valerie
found another mysterious thing (for me :-)):
As I wrote before the datasource is assigned at runtime and I use Paging too.But when the PageIndex changed the datasource is gone (nothing) so I only see data on the first page.