Manual Bind and Dynmic Columns via Code Behind

7 replies. Last post: February 22, 2010 10:15 PM by Yudi
Tags :
  • (None)
  • New Discussion
  • New Question
  • New Product Feedback
place DanielMember

I know how to manually add a column via code behind to the grid roottable, but when I do the actual databind all the columns show up inthe grid.  I only want to paint a certain number of them.   I only want the columns I'm adding the grid from the BuildColumns() function below, but it binds all rows coming back form the GetGridData.  For example, the dataset returns back first name, last name and ssn.  I just want to display last name in the grid but want to bind it to the dataset. What's the best way to accomplish this?  Is it a timing issue I'm hitting?  Any help would be greatly appreciated!

 

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load If Page.IsPostBack = False Then

BuildColumns()

SetGridProperties()

BindGridData()

Private Sub BuildColumns()

Dim columnList As ArrayList = GetReportColumns(True) Dim gridColumn As GridColumn For Each gridColumn In columnList Dim newGC As New WebGridColumn(gridColumn.DisplayName, gridColumn.DataName, gridColumn.DisplayName)

newGC.AllowSorting = Sorting.Yes

Grid.RootTable.Columns.Add(newGC)

Next End Sub

 

Private Sub BindGridData()

GridView.DataSource = GetGridData()

GridView.DataBind()

End Sub

 

Private Function GetGridData() As DataSet Return DataMapping.GetSourceDataCall(CType(ReportID, Int64), ReportParameters) End Function
All times are GMT -5. The time now is 3:25 AM.
Previous Next