create header row for gridview in code-behind before binding
-
Hi, I would like to know how I can add a headerRow to a gridview, before I show it on the page. I will never know how many columns there will be(get amount of columns from another source), so I have to loop through an array each time, check how many columms there are, and then create a column(with text name) for each of the array items. How will I add code to the following code, to add a header row?
'dtInvoice = datatable 'gdvInvoice = gridview gdvInvoice.DataSource = dtInvoice gdvInvoice.EmptyDataText = "No Data to Display" gdvInvoice.PagerSettings.Position = PagerPosition.Top gdvInvoice.AllowSorting = True Dim keyArray() As String = {ViewState("AppPrimaryKey")} gdvInvoice.DataKeyNames = keyArray gdvInvoice.DataBind() gdvInvoice.Visible = True