|
I am binding the data to datagrind at run time:
.DataSource = GetData()
.DataBind()
How do I hide a column 2 ?
|
|
|
Do you want to hide the column, or the controls within the column? Are you using templates?
If you don't want a column to render, the best way is to remove the column from your datasource.
|
|
|
|
|
I need to show sometimes that column. No it is not a template
|
|
|
Can you show any of your code? Even better, can you post a link to the site? I want to see what kind of table structure it creates.
If you don't want to link, then run the page, and do a "view source". Post the table that the datagrid renders.
|
|
|
|
|
Private Sub btnSearch_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSearch.Click
With grdSearchResult
.SelectedIndex = -1
.DataSource = GetData()
.DataBind()
End With
End Sub
GetData() - just a dataset
|
|
|
I'd like to help, but "Just a DataSet" isn't informative. How many DataTables are in the DataSet? How have they been constructed? Do you have DataViews in the DataSet? How are you creating DataRows and DataColumns?
Also, I need to see the HTML rendered by the DataGrid. This is because there may be a way to hide columns on the client, using JavaScript.
Also, it would be helpful to see the "HTML" view of the aspx page. In Visual Studio, in the Design Window, you have an "HTML" tab. This shows the datagrid control declaration. I'd like to see that.
|
|
|
|
|
I found. here is hte answer:
Private Sub grdSearchResult_ItemDataBound(ByVal sender As System.Object, ByVal e As System.Web.UI.WebControls.DataGridItemEventArgs) Handles grdSearchResult.ItemDataBound
e.Item.Cells(1).Visible = False
End Sub
|
|
|