GridView is used in showing information in a tabular form, GridView replaced the Datagrid which was used in asp.net 1.1, if you are working in asp.net 2.0
then you are facing a problem which is that you can not hide a particular column if you want but in asp.net 1.1 you can do it by simply making the visible
property false,hat it so simple but in asp.net 2.0 its not so easy, but if problem is there, chances of solution is also there
I will tell you 2 method to deal with this type of problem
1). Create the Row Created event handler and do the following:
Public Sub myGrid_OnRowCreated(ByVal sender As Object, ByVal e As Web.UI.WebControls.GridViewRowEventArgs) Handles myGrid.RowCreated
'Those columns you don't want to display you config here,
'you could use a for statement if you have many
e.Row.Cells(1).Visible = False
2) Public Sub myTestFunction()
'To hide a column, set its width to zero or use MappingType
Dim strCON As String = ""
Dim strQuery As String = ""
Dim da As Data.SqlClient.SqlDataAdapter
Dim ds As Data.DataSet
Dim conn As New Data.SqlClient.SqlConnection(strCON)
da = New Data.SqlClient.SqlDataAdapter(strQuery, CON)
ds = New Data.DataSet
Catch ex As Exception
'Do error handling here...
'Here you can HIDE the Column
ds.Tables("tblData").Columns(colIndex).ColumnMapping = Data.MappingType.Hidden
myGrid.DataSource = ds.Tables("tblData")
by use these methods we can hide the columns of GridView as we wish.
About the author:
Note: Due to the size or complexity of this submission, the author has submitted it as a .zip file to shorten your download time. After downloading it, you will need a program like Winzip to decompress it.
Virus note: All files are scanned once-a-day by SourceCodester.com for viruses, but new viruses come out every day, so no prevention program can catch 100% of them.
FOR YOUR OWN SAFETY, PLEASE:
1. Re-scan downloaded files using your personal virus checker before using it.
2. NEVER, EVER run compiled files (.exe's, .ocx's, .dll's etc.)--only run source code.