﻿<?xml version="1.0" encoding="utf-8"?><rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:sy="http://purl.org/rss/1.0/modules/syndication/" xmlns:media="http://search.yahoo.com/mrss/" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0"><channel><title>Intersoft Community - WebGrid Enterprise - Manual Bind and Dynmic Columns via Code Behind</title><link>http://www.intersoftsolutions.com/Community/WebGrid/Manual-Bind-and-Dynmic-Columns-via-Code-Behind/</link><description /><generator>http://www.intersoftsolutions.com</generator><language>en</language><copyright>Copyright 2002 - 2015 Intersoft Solutions Corp. All rights reserved.</copyright><ttl>60</ttl><item><title>Manual Bind and Dynmic Columns via Code Behind</title><link>http://www.intersoftsolutions.com/Community/WebGrid/Manual-Bind-and-Dynmic-Columns-via-Code-Behind/</link><pubDate>Mon, 22 Feb 2010 22:15:10 GMT</pubDate><dc:creator>yudi</dc:creator><description>&lt;p&gt;&lt;span style="font-family: 'segoe ui','sans-serif'; color: #1f497d; font-size: 9pt"&gt;In the simple sample as shown below, the grouping works.&lt;/span&gt;&lt;/p&gt;&lt;blockquote&gt;&lt;pre&gt;Protected Sub WebGrid1_PrepareDataBinding(ByVal sender As Object, ByVal e As ISNet.WebUI.WebGrid.DataSourceEventArgs)
    Dim ColumnSet As String = ""

    ' make sure the codes only executed on page postback, but not an OnTheFly postback.
    If IsPostBack AndAlso (Not WebGrid1.IsFlyPostBack) Then
        If clickFlag = 1 OrElse clickFlag = 2 Then
            If clickFlag = 1 Then
                ColumnSet = ("CustomerID,CompanyName,ContactName,ContactTitle")
            Else
                ColumnSet = ("CustomerID,Country,Region,PostalCode")
            End If

            ' clear all columns before repopulated
            WebGrid1.RootTable.Columns.Clear()
            WebGrid1.RootTable.SortedColumns.Clear()
             WebGrid1.RootTable.GroupedColumns.Clear()

            Dim Columns As String() = ColumnSet.Split(","c)
            For Each Column As String In Columns
                Dim col As WebGridColumn = New WebGridColumn()
                col.DataMember = Column
                col.Caption = Column

                WebGrid1.RootTable.Columns.Add(col)
            Next Column
        ElseIf clickFlag = 3 Then
            WebGrid1.RootTable.SortedColumns.Clear()
            WebGrid1.RootTable.GroupedColumns.Clear()

            WebGrid1.RetrieveStructure()

            Dim groupByCountry As WebGridGroup = New WebGridGroup()
            groupByCountry.ColumnMember = "Country"
            groupByCountry.GroupInterval = GroupInterval.Default
            groupByCountry.SortOrder = SortOrder.Ascending
            WebGrid1.RootTable.GroupedColumns.Add(groupByCountry)
        End If
    End If
End Sub&lt;/pre&gt;&lt;/blockquote&gt;
&lt;p&gt;&lt;span style="font-family: 'segoe ui','sans-serif'; color: #1f497d; font-size: 9pt"&gt;There should be no timing issue when using this sample since every single event is invoked synchronously.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: 'segoe ui','sans-serif'; color: #1f497d; font-size: 9pt"&gt;I can’t have your sent sample run on my end because it uses some methods, classes, object, etc that is not available within the sample. If the issue is replicable in a running simple sample it will be so much helpful to be investigated further. If necessary, you may modify my sent sample so it replicates your issue and then have the sample sent back to us to be analyzed.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: 'segoe ui','sans-serif'; color: #1f497d; font-size: 9pt"&gt;Thank you and look forward for your response.&lt;/span&gt;&lt;/p&gt;</description></item><item><title>Manual Bind and Dynmic Columns via Code Behind</title><link>http://www.intersoftsolutions.com/Community/WebGrid/Manual-Bind-and-Dynmic-Columns-via-Code-Behind/</link><pubDate>Mon, 22 Feb 2010 07:30:05 GMT</pubDate><dc:creator>pmdaniel</dc:creator><description>&lt;p&gt;Hi - It is one of the columns. I tried with a few others as well to no avail. Could it be a timing issue with when the grid builds out the columns from the GetReportColumns() and the creation of the groupby column?  If I add it to the .ascx instead of dynamically adding it, it works. &lt;/p&gt;</description></item><item><title>Manual Bind and Dynmic Columns via Code Behind</title><link>http://www.intersoftsolutions.com/Community/WebGrid/Manual-Bind-and-Dynmic-Columns-via-Code-Behind/</link><pubDate>Mon, 22 Feb 2010 00:23:17 GMT</pubDate><dc:creator>yudi</dc:creator><description>&lt;p&gt;&lt;span style="font-family: 'segoe ui','sans-serif'; color: #1f497d; font-size: 9pt"&gt;GroupedColumns can only be added on an existing column in WebGrid structure. If the column is not exist, then it will shows the error you get, “Object reference not set to an instance of an object.”.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: 'segoe ui','sans-serif'; color: #1f497d; font-size: 9pt"&gt;Please ensure that the “GetReportsColumns()” method return “vchHHName” column.&lt;/span&gt;&lt;/p&gt;</description></item><item><title>Manual Bind and Dynmic Columns via Code Behind</title><link>http://www.intersoftsolutions.com/Community/WebGrid/Manual-Bind-and-Dynmic-Columns-via-Code-Behind/</link><pubDate>Fri, 12 Feb 2010 09:10:37 GMT</pubDate><dc:creator>pmdaniel</dc:creator><description>&lt;p&gt;I implmented the same code except for a few differences. I try to perform the groupby without first clicking on a button. I don't need to run the &lt;span style="color: #008000; font-size: 13px"&gt;&lt;span style="color: #008000; font-size: 13px"&gt;RetrieveStructure&lt;/span&gt;&lt;/span&gt; function. If I add the column to the ascx side under the   &amp;lt;roottable&amp;gt; &amp;lt;columns&amp;gt; section like below it works. But I don't know the column names so I can't do that.  Once I remove the &lt;span style="color: #a31515; font-size: 13px"&gt;&lt;span style="color: #a31515; font-size: 13px"&gt;WebGridColumn&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: 13px"&gt; from below &lt;/span&gt;it gives me the error assuming oI'm doing my grouping on the vchHHName.  If I try to do my grouping on any other column that I don't include below it fails.&lt;/p&gt;
&lt;p&gt; &lt;/p&gt;&lt;span style="font-size: 13px"&gt;&lt;/span&gt;&lt;span style="color: #0000ff; font-size: 13px"&gt;&lt;span style="color: #0000ff; font-size: 13px"&gt;&amp;lt;&lt;/span&gt;&lt;/span&gt;&lt;span style="color: #a31515; font-size: 13px"&gt;&lt;span style="color: #a31515; font-size: 13px"&gt;Columns&lt;/span&gt;&lt;/span&gt;&lt;span style="color: #0000ff; font-size: 13px"&gt;&lt;span style="color: #0000ff; font-size: 13px"&gt;&amp;gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: 13px"&gt;&lt;/span&gt;&lt;span style="color: #0000ff; font-size: 13px"&gt;&lt;span style="color: #0000ff; font-size: 13px"&gt;&amp;lt;&lt;/span&gt;&lt;/span&gt;&lt;span style="color: #a31515; font-size: 13px"&gt;&lt;span style="color: #a31515; font-size: 13px"&gt;iswebgrid&lt;/span&gt;&lt;/span&gt;&lt;span style="color: #0000ff; font-size: 13px"&gt;&lt;span style="color: #0000ff; font-size: 13px"&gt;:&lt;/span&gt;&lt;/span&gt;&lt;span style="color: #a31515; font-size: 13px"&gt;&lt;span style="color: #a31515; font-size: 13px"&gt;WebGridColumn&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: 13px"&gt; &lt;/span&gt;&lt;span style="color: #ff0000; font-size: 13px"&gt;&lt;span style="color: #ff0000; font-size: 13px"&gt;Caption&lt;/span&gt;&lt;/span&gt;&lt;span style="color: #0000ff; font-size: 13px"&gt;&lt;span style="color: #0000ff; font-size: 13px"&gt;="vchHHName"&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: 13px"&gt; &lt;/span&gt;&lt;span style="color: #ff0000; font-size: 13px"&gt;&lt;span style="color: #ff0000; font-size: 13px"&gt;DataMember&lt;/span&gt;&lt;/span&gt;&lt;span style="color: #0000ff; font-size: 13px"&gt;&lt;span style="color: #0000ff; font-size: 13px"&gt;="vchHHName"&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: 13px"&gt; &lt;/span&gt;&lt;span style="color: #ff0000; font-size: 13px"&gt;&lt;span style="color: #ff0000; font-size: 13px"&gt;Name&lt;/span&gt;&lt;/span&gt;&lt;span style="color: #0000ff; font-size: 13px"&gt;&lt;span style="color: #0000ff; font-size: 13px"&gt;="vchHHName"&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: 13px"&gt; &lt;/span&gt;&lt;span style="color: #ff0000; font-size: 13px"&gt;&lt;span style="color: #ff0000; font-size: 13px"&gt;Width&lt;/span&gt;&lt;/span&gt;&lt;span style="color: #0000ff; font-size: 13px"&gt;&lt;span style="color: #0000ff; font-size: 13px"&gt;="100px"&amp;gt;&amp;lt;/&lt;/span&gt;&lt;/span&gt;&lt;span style="color: #a31515; font-size: 13px"&gt;&lt;span style="color: #a31515; font-size: 13px"&gt;iswebgrid&lt;/span&gt;&lt;/span&gt;&lt;span style="color: #0000ff; font-size: 13px"&gt;&lt;span style="color: #0000ff; font-size: 13px"&gt;:&lt;/span&gt;&lt;/span&gt;&lt;span style="color: #a31515; font-size: 13px"&gt;&lt;span style="color: #a31515; font-size: 13px"&gt;WebGridColumn&lt;/span&gt;&lt;/span&gt;&lt;span style="color: #0000ff; font-size: 13px"&gt;&lt;span style="color: #0000ff; font-size: 13px"&gt;&amp;gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: 13px"&gt;&lt;/span&gt;&lt;span style="color: #0000ff; font-size: 13px"&gt;&lt;span style="color: #0000ff; font-size: 13px"&gt;&amp;lt;/&lt;/span&gt;&lt;/span&gt;&lt;span style="color: #a31515; font-size: 13px"&gt;&lt;span style="color: #a31515; font-size: 13px"&gt;Columns&lt;/span&gt;&lt;/span&gt;&lt;span style="color: #0000ff; font-size: 13px"&gt;&lt;span style="color: #0000ff; font-size: 13px"&gt;&amp;gt;
&lt;/span&gt;&lt;/span&gt;</description></item><item><title>Manual Bind and Dynmic Columns via Code Behind</title><link>http://www.intersoftsolutions.com/Community/WebGrid/Manual-Bind-and-Dynmic-Columns-via-Code-Behind/</link><pubDate>Thu, 11 Feb 2010 23:18:47 GMT</pubDate><dc:creator>yudi</dc:creator><description>&lt;p&gt;&lt;span style="font-family: 'segoe ui','sans-serif'; color: #1f497d; font-size: 9pt"&gt;I was unable to repro your issue using the sample I attach on my previous post.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: 'segoe ui','sans-serif'; color: #1f497d; font-size: 9pt"&gt;I made a minor modification to the sample I sent you before in order to add WebGrid GroupedColumn in PrepareDataBinding event. Below is the snippet of the changes.&lt;/span&gt;&lt;/p&gt;&lt;pre&gt;Protected Sub WebGrid1_PrepareDataBinding(ByVal sender As Object, ByVal e As ISNet.WebUI.WebGrid.DataSourceEventArgs)
    Dim ColumnSet As String = ""

    ' make sure the codes only executed on page postback, but not an OnTheFly postback.
    If IsPostBack AndAlso (Not WebGrid1.IsFlyPostBack) Then
        If clickFlag = 1 OrElse clickFlag = 2 Then
            If clickFlag = 1 Then
                ColumnSet = ("CustomerID,CompanyName,ContactName,ContactTitle")
            Else
                ColumnSet = ("CustomerID,Country,Region,PostalCode")
            End If

            ' clear all columns before repopulated
            WebGrid1.RootTable.Columns.Clear()
            WebGrid1.RootTable.SortedColumns.Clear()
             WebGrid1.RootTable.GroupedColumns.Clear()

            Dim Columns As String() = ColumnSet.Split(","c)
            For Each Column As String In Columns
                Dim col As WebGridColumn = New WebGridColumn()
                col.DataMember = Column
                col.Caption = Column

                WebGrid1.RootTable.Columns.Add(col)
            Next Column
        ElseIf clickFlag = 3 Then
            WebGrid1.RootTable.SortedColumns.Clear()
            WebGrid1.RootTable.GroupedColumns.Clear()

            WebGrid1.RetrieveStructure()

            Dim groupByCountry As WebGridGroup = New WebGridGroup()
            groupByCountry.ColumnMember = "Country"
            groupByCountry.GroupInterval = GroupInterval.Default
            groupByCountry.SortOrder = SortOrder.Ascending
            WebGrid1.RootTable.GroupedColumns.Add(groupByCountry)
        End If
    End If
End Sub&lt;/pre&gt;

&lt;p&gt; &lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: 'segoe ui','sans-serif'; color: #1f497d; font-size: 9pt"&gt;The grouped columns works fine and no problem persist. If you still have the issue, could you please modify the sample I sent you (so that it replicates your issue) and then have the sample sent back to us for further investigation?&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: 'segoe ui','sans-serif'; color: #1f497d; font-size: 9pt"&gt;Hope this helps.&lt;/span&gt;&lt;/p&gt;</description></item><item><title>Manual Bind and Dynmic Columns via Code Behind</title><link>http://www.intersoftsolutions.com/Community/WebGrid/Manual-Bind-and-Dynmic-Columns-via-Code-Behind/</link><pubDate>Thu, 11 Feb 2010 10:59:51 GMT</pubDate><dc:creator>pmdaniel</dc:creator><description>&lt;p&gt;Thanks. That worked!  I actually had to declare the functions in the aspx code the intialize and databinding code. I tried just to use the default functions in the code behind for the grid and some how that didn't work. Now, my dynamic grouping does not work, but I should be able to resolve that. It gives an object reference not found error. I tried placing it in the &lt;span style="font-size: 13px"&gt;WebGrid1_PrepareDataBinding &lt;/span&gt;event and also the &lt;span style="font-size: 13px"&gt;WebGrid1_InitializeLayout to no avail.&amp;nbsp; I know the column exists. Here's the error and code:&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-size: 13px"&gt;&lt;em&gt;Error: Object reference not set to an instance of an object.&lt;/em&gt; &lt;/span&gt;&lt;/p&gt;&lt;span style="font-size: 13px"&gt;&lt;span style="font-size: 13px"&gt;&lt;/span&gt;&lt;span style="color: #0000ff; font-size: 13px"&gt;&lt;span style="color: #0000ff; font-size: 13px"&gt;Protected&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: 13px"&gt; &lt;/span&gt;&lt;span style="color: #0000ff; font-size: 13px"&gt;&lt;span style="color: #0000ff; font-size: 13px"&gt;Sub&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: 13px"&gt; WebGrid1_PrepareDataBinding(&lt;/span&gt;&lt;span style="color: #0000ff; font-size: 13px"&gt;&lt;span style="color: #0000ff; font-size: 13px"&gt;ByVal&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: 13px"&gt; sender &lt;/span&gt;&lt;span style="color: #0000ff; font-size: 13px"&gt;&lt;span style="color: #0000ff; font-size: 13px"&gt;As&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: 13px"&gt; &lt;/span&gt;&lt;span style="color: #0000ff; font-size: 13px"&gt;&lt;span style="color: #0000ff; font-size: 13px"&gt;Object&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: 13px"&gt;, &lt;/span&gt;&lt;span style="color: #0000ff; font-size: 13px"&gt;&lt;span style="color: #0000ff; font-size: 13px"&gt;ByVal&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: 13px"&gt; e &lt;/span&gt;&lt;span style="color: #0000ff; font-size: 13px"&gt;&lt;span style="color: #0000ff; font-size: 13px"&gt;As&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: 13px"&gt; ISNet.WebUI.WebGrid.DataSourceEventArgs) &lt;/span&gt;&lt;span style="color: #008000; font-size: 13px"&gt;&lt;span style="color: #008000; font-size: 13px"&gt;''set the sorting in here&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: 13px"&gt; &lt;/span&gt;&lt;span style="color: #0000ff; font-size: 13px"&gt;&lt;span style="color: #0000ff; font-size: 13px"&gt;Dim&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: 13px"&gt; ColumnSet &lt;/span&gt;&lt;span style="color: #0000ff; font-size: 13px"&gt;&lt;span style="color: #0000ff; font-size: 13px"&gt;As&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: 13px"&gt; &lt;/span&gt;&lt;span style="color: #0000ff; font-size: 13px"&gt;&lt;span style="color: #0000ff; font-size: 13px"&gt;String&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: 13px"&gt; = &lt;/span&gt;&lt;span style="color: #a31515; font-size: 13px"&gt;&lt;span style="color: #a31515; font-size: 13px"&gt;""&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: 13px"&gt; &lt;/span&gt;&lt;span style="color: #0000ff; font-size: 13px"&gt;&lt;span style="color: #0000ff; font-size: 13px"&gt;Dim&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: 13px"&gt; columnList &lt;/span&gt;&lt;span style="color: #0000ff; font-size: 13px"&gt;&lt;span style="color: #0000ff; font-size: 13px"&gt;As&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: 13px"&gt; ArrayList = GetReportColumns(&lt;/span&gt;&lt;span style="color: #0000ff; font-size: 13px"&gt;&lt;span style="color: #0000ff; font-size: 13px"&gt;True&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: 13px"&gt;) &lt;/span&gt;&lt;span style="color: #0000ff; font-size: 13px"&gt;&lt;span style="color: #0000ff; font-size: 13px"&gt;Dim&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: 13px"&gt; gridColumn &lt;/span&gt;&lt;span style="color: #0000ff; font-size: 13px"&gt;&lt;span style="color: #0000ff; font-size: 13px"&gt;As&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: 13px"&gt; GridColumn &lt;/span&gt;&lt;span style="color: #0000ff; font-size: 13px"&gt;&lt;span style="color: #0000ff; font-size: 13px"&gt;With&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: 13px"&gt; reportGrid.RootTable 
&lt;p&gt;.Columns.Clear()&lt;/p&gt;
&lt;p&gt;.SortedColumns.Clear()&lt;/p&gt;&lt;/span&gt;&lt;span style="color: #008000; font-size: 13px"&gt;&lt;span style="color: #008000; font-size: 13px"&gt;.GroupedColumns.Clear()&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: 13px"&gt; &lt;/span&gt;&lt;span style="color: #0000ff; font-size: 13px"&gt;&lt;span style="color: #0000ff; font-size: 13px"&gt;End&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: 13px"&gt; &lt;/span&gt;&lt;span style="color: #0000ff; font-size: 13px"&gt;&lt;span style="color: #0000ff; font-size: 13px"&gt;With&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: 13px"&gt; &lt;/span&gt;&lt;span style="color: #0000ff; font-size: 13px"&gt;&lt;span style="color: #0000ff; font-size: 13px"&gt;For&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: 13px"&gt; &lt;/span&gt;&lt;span style="color: #0000ff; font-size: 13px"&gt;&lt;span style="color: #0000ff; font-size: 13px"&gt;Each&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: 13px"&gt; gridColumn &lt;/span&gt;&lt;span style="color: #0000ff; font-size: 13px"&gt;&lt;span style="color: #0000ff; font-size: 13px"&gt;In&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: 13px"&gt; columnList &lt;/span&gt;&lt;span style="color: #0000ff; font-size: 13px"&gt;&lt;span style="color: #0000ff; font-size: 13px"&gt;Dim&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: 13px"&gt; col &lt;/span&gt;&lt;span style="color: #0000ff; font-size: 13px"&gt;&lt;span style="color: #0000ff; font-size: 13px"&gt;As&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: 13px"&gt; &lt;/span&gt;&lt;span style="color: #0000ff; font-size: 13px"&gt;&lt;span style="color: #0000ff; font-size: 13px"&gt;New&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: 13px"&gt; WebGridColumn(gridColumn.DisplayName, gridColumn.DataName, gridColumn.DisplayName) 
&lt;p&gt;reportGrid.RootTable.Columns.Add(col)&lt;/p&gt;&lt;/span&gt;&lt;span style="color: #0000ff; font-size: 13px"&gt;&lt;span style="color: #0000ff; font-size: 13px"&gt;Next&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: 13px"&gt; &lt;/span&gt;&lt;span style="color: #0000ff; font-size: 13px"&gt;&lt;span style="color: #0000ff; font-size: 13px"&gt;Dim&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: 13px"&gt; groupBy &lt;/span&gt;&lt;span style="color: #0000ff; font-size: 13px"&gt;&lt;span style="color: #0000ff; font-size: 13px"&gt;As&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: 13px"&gt; WebGridGroup = &lt;/span&gt;&lt;span style="color: #0000ff; font-size: 13px"&gt;&lt;span style="color: #0000ff; font-size: 13px"&gt;New&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: 13px"&gt; WebGridGroup() 
&lt;p&gt;groupBy.ColumnMember = &lt;span style="color: #a31515; font-size: 13px"&gt;&lt;span style="color: #a31515; font-size: 13px"&gt;"vchHHName"&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;/span&gt;&lt;span style="font-size: 13px"&gt;
&lt;p&gt;groupBy.GroupInterval = GroupInterval.Text&lt;/p&gt;
&lt;p&gt;groupBy.SortOrder = SortOrder.Ascending&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;reportGrid.RootTable.GroupedColumns.Add(groupBy) ''it errors due to this line&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;End Sub&lt;/p&gt;&lt;/span&gt;&lt;/span&gt;</description></item><item><title>Manual Bind and Dynmic Columns via Code Behind</title><link>http://www.intersoftsolutions.com/Community/WebGrid/Manual-Bind-and-Dynmic-Columns-via-Code-Behind/</link><pubDate>Thu, 11 Feb 2010 01:44:43 GMT</pubDate><dc:creator>yudi</dc:creator><description>&lt;p&gt;&lt;span style="font-family: 'segoe ui','sans-serif'; color: #1f497d; font-size: 9pt"&gt;I enclosed one simple sample of WebGrid that shows how to bind WebGrid manually and display different column via code behind.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: 'segoe ui','sans-serif'; color: #1f497d; font-size: 9pt"&gt;I suggest you to do data source initialization in InitializeDataSource event and column structure retrieval in PrepareDataBinding event. The advantage of following this style is to utilize the advantages of WebGrid component extensively such as data caching feature is enabled if the assignment of WebGrid data source is placed in InitializeDataSource event.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: 'segoe ui','sans-serif'; color: #1f497d; font-size: 9pt"&gt;&lt;strong&gt;WebGrid_InitializeDataSource event&lt;/strong&gt;&lt;br /&gt;All codes related to the assignment of data source to the WebGrid component should be placed here. Codes that related to the DataTable structure creation, DataSet populating process with the DataAdapter and so many data related task could be processed here. In the conclusion, only data populating related codes should be placed here, no process of assigning WebGrid layout should be placed as depicted from the event name (InitializeDataSource).&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: 'segoe ui','sans-serif'; color: #1f497d; font-size: 9pt"&gt;&lt;strong&gt;WebGrid_PrepareDataBinding event&lt;/strong&gt;&lt;br /&gt;In this event, developers can conveniently populate all the columns structure. When the InitializeDataSource event is invoked and the codes inside the InitializeDataSource event are executed, WebGrid will proceed to invoke the PrepareDataBinding event automatically.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: 'segoe ui','sans-serif'; color: #1f497d; font-size: 9pt"&gt;&lt;strong&gt;WebGrid_InitializeLayout event&lt;/strong&gt;&lt;br /&gt;InitializeLayout event is originally designed to let developers programmatically configure static WebGrid’s behavior, appearance, look and feel, style, etc.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family: 'segoe ui','sans-serif'; color: #1f497d; font-size: 9pt"&gt;For more detail information about the event sequence of server side event in WebGrid, please check WebGrid documentation. Hope this helps.&lt;/span&gt;&lt;/p&gt;</description></item><item><title>Manual Bind and Dynmic Columns via Code Behind</title><link>http://www.intersoftsolutions.com/Community/WebGrid/Manual-Bind-and-Dynmic-Columns-via-Code-Behind/</link><pubDate>Wed, 10 Feb 2010 10:18:32 GMT</pubDate><dc:creator>pmdaniel</dc:creator><description>&lt;p&gt;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!&lt;/p&gt;
&lt;p&gt; &lt;/p&gt;&lt;span style="font-size: 13px"&gt;&lt;span style="font-size: 13px"&gt;&lt;/span&gt;&lt;span style="color: #0000ff; font-size: 13px"&gt;&lt;span style="color: #0000ff; font-size: 13px"&gt;Protected&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: 13px"&gt; &lt;/span&gt;&lt;span style="color: #0000ff; font-size: 13px"&gt;&lt;span style="color: #0000ff; font-size: 13px"&gt;Sub&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: 13px"&gt; Page_Load(&lt;/span&gt;&lt;span style="color: #0000ff; font-size: 13px"&gt;&lt;span style="color: #0000ff; font-size: 13px"&gt;ByVal&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: 13px"&gt; sender &lt;/span&gt;&lt;span style="color: #0000ff; font-size: 13px"&gt;&lt;span style="color: #0000ff; font-size: 13px"&gt;As&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: 13px"&gt; &lt;/span&gt;&lt;span style="color: #0000ff; font-size: 13px"&gt;&lt;span style="color: #0000ff; font-size: 13px"&gt;Object&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: 13px"&gt;, &lt;/span&gt;&lt;span style="color: #0000ff; font-size: 13px"&gt;&lt;span style="color: #0000ff; font-size: 13px"&gt;ByVal&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: 13px"&gt; e &lt;/span&gt;&lt;span style="color: #0000ff; font-size: 13px"&gt;&lt;span style="color: #0000ff; font-size: 13px"&gt;As&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: 13px"&gt; System.EventArgs) &lt;/span&gt;&lt;span style="color: #0000ff; font-size: 13px"&gt;&lt;span style="color: #0000ff; font-size: 13px"&gt;Handles&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: 13px"&gt; &lt;/span&gt;&lt;span style="color: #0000ff; font-size: 13px"&gt;&lt;span style="color: #0000ff; font-size: 13px"&gt;Me&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: 13px"&gt;.Load &lt;/span&gt;&lt;span style="color: #0000ff; font-size: 13px"&gt;&lt;span style="color: #0000ff; font-size: 13px"&gt;If&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: 13px"&gt; Page.IsPostBack = &lt;/span&gt;&lt;span style="color: #0000ff; font-size: 13px"&gt;&lt;span style="color: #0000ff; font-size: 13px"&gt;False&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: 13px"&gt; &lt;/span&gt;&lt;span style="color: #0000ff; font-size: 13px"&gt;&lt;span style="color: #0000ff; font-size: 13px"&gt;Then &lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: 13px"&gt;
&lt;p&gt;BuildColumns()&lt;/p&gt;
&lt;p&gt;SetGridProperties()&lt;/p&gt;
&lt;p&gt;BindGridData()&lt;/p&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span /&gt;&lt;span style="color: #0000ff; font-size: 13px"&gt;&lt;span style="color: #0000ff; font-size: 13px"&gt;&lt;/span&gt;&lt;/span&gt;
&lt;p&gt;&lt;span style="color: #0000ff; font-size: 13px"&gt;&lt;span style="color: #0000ff; font-size: 13px"&gt;Private&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: 13px"&gt; &lt;/span&gt;&lt;span style="color: #0000ff; font-size: 13px"&gt;&lt;span style="color: #0000ff; font-size: 13px"&gt;Sub&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: 13px"&gt; BuildColumns() &lt;/span&gt;&lt;/p&gt;&lt;span style="color: #0000ff; font-size: 13px"&gt;&lt;span style="color: #0000ff; font-size: 13px"&gt;Dim&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: 13px"&gt; columnList &lt;/span&gt;&lt;span style="color: #0000ff; font-size: 13px"&gt;&lt;span style="color: #0000ff; font-size: 13px"&gt;As&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: 13px"&gt; ArrayList = GetReportColumns(&lt;/span&gt;&lt;span style="color: #0000ff; font-size: 13px"&gt;&lt;span style="color: #0000ff; font-size: 13px"&gt;True&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: 13px"&gt;) &lt;/span&gt;&lt;span style="color: #0000ff; font-size: 13px"&gt;&lt;span style="color: #0000ff; font-size: 13px"&gt;Dim&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: 13px"&gt; gridColumn &lt;/span&gt;&lt;span style="color: #0000ff; font-size: 13px"&gt;&lt;span style="color: #0000ff; font-size: 13px"&gt;As&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: 13px"&gt; GridColumn &lt;/span&gt;&lt;span style="color: #0000ff; font-size: 13px"&gt;&lt;span style="color: #0000ff; font-size: 13px"&gt;For&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: 13px"&gt; &lt;/span&gt;&lt;span style="color: #0000ff; font-size: 13px"&gt;&lt;span style="color: #0000ff; font-size: 13px"&gt;Each&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: 13px"&gt; gridColumn &lt;/span&gt;&lt;span style="color: #0000ff; font-size: 13px"&gt;&lt;span style="color: #0000ff; font-size: 13px"&gt;In&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: 13px"&gt; columnList &lt;/span&gt;&lt;span style="color: #0000ff; font-size: 13px"&gt;&lt;span style="color: #0000ff; font-size: 13px"&gt;Dim&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: 13px"&gt; newGC &lt;/span&gt;&lt;span style="color: #0000ff; font-size: 13px"&gt;&lt;span style="color: #0000ff; font-size: 13px"&gt;As&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: 13px"&gt; &lt;/span&gt;&lt;span style="color: #0000ff; font-size: 13px"&gt;&lt;span style="color: #0000ff; font-size: 13px"&gt;New&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: 13px"&gt; WebGridColumn(gridColumn.DisplayName, gridColumn.DataName, gridColumn.DisplayName&lt;/span&gt;&lt;span style="font-size: 13px"&gt;) &lt;p&gt;newGC.AllowSorting = Sorting.Yes&lt;/p&gt;&lt;p&gt;Grid.RootTable.Columns.Add(newGC)&lt;/p&gt;&lt;/span&gt;&lt;span style="color: #0000ff; font-size: 13px"&gt;&lt;span style="color: #0000ff; font-size: 13px"&gt;Next &lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: 13px"&gt;&lt;/span&gt;&lt;span style="color: #0000ff; font-size: 13px"&gt;&lt;span style="color: #0000ff; font-size: 13px"&gt;End&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: 13px"&gt; &lt;/span&gt;&lt;span style="color: #0000ff; font-size: 13px"&gt;&lt;span style="color: #0000ff; font-size: 13px"&gt;Sub&lt;/span&gt;&lt;/span&gt; 
&lt;p&gt;&lt;span style="color: #0000ff; font-size: 13px"&gt;&lt;span style="color: #0000ff; font-size: 13px"&gt;&lt;/span&gt;&lt;/span&gt; &lt;/p&gt;&lt;span style="color: #0000ff; font-size: 13px"&gt;&lt;span style="color: #0000ff; font-size: 13px"&gt;&lt;span style="font-size: 13px"&gt;&lt;/span&gt;&lt;span style="color: #0000ff; font-size: 13px"&gt;&lt;span style="color: #0000ff; font-size: 13px"&gt;Private&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: 13px"&gt; &lt;/span&gt;&lt;span style="color: #0000ff; font-size: 13px"&gt;&lt;span style="color: #0000ff; font-size: 13px"&gt;Sub&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: 13px"&gt; BindGridData() &lt;p&gt;GridView.DataSource = GetGridData()&lt;/p&gt;&lt;p&gt;GridView.DataBind()&lt;/p&gt;&lt;/span&gt;&lt;span style="color: #0000ff; font-size: 13px"&gt;&lt;span style="color: #0000ff; font-size: 13px"&gt;End&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: 13px"&gt; &lt;/span&gt;&lt;span style="color: #0000ff; font-size: 13px"&gt;&lt;span style="color: #0000ff; font-size: 13px"&gt;Sub&lt;/span&gt;&lt;/span&gt; 
&lt;p&gt;&lt;span style="color: #0000ff; font-size: 13px"&gt;&lt;span style="color: #0000ff; font-size: 13px"&gt;&lt;/span&gt;&lt;/span&gt; &lt;/p&gt;&lt;span style="color: #0000ff; font-size: 13px"&gt;&lt;span style="color: #0000ff; font-size: 13px"&gt;&lt;span style="font-size: 13px"&gt;&lt;/span&gt;&lt;span style="color: #0000ff; font-size: 13px"&gt;&lt;span style="color: #0000ff; font-size: 13px"&gt;Private&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: 13px"&gt; &lt;/span&gt;&lt;span style="color: #0000ff; font-size: 13px"&gt;&lt;span style="color: #0000ff; font-size: 13px"&gt;Function&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: 13px"&gt; GetGridData() &lt;/span&gt;&lt;span style="color: #0000ff; font-size: 13px"&gt;&lt;span style="color: #0000ff; font-size: 13px"&gt;As&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: 13px"&gt; DataSet&lt;/span&gt;&lt;span style="color: #0000ff; font-size: 13px"&gt;&lt;span style="color: #0000ff; font-size: 13px"&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: 13px"&gt;&lt;/span&gt;&lt;span style="color: #0000ff; font-size: 13px"&gt;&lt;span style="color: #0000ff; font-size: 13px"&gt;Return&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: 13px"&gt; DataMapping.GetSourceDataCall(&lt;/span&gt;&lt;span style="color: #0000ff; font-size: 13px"&gt;&lt;span style="color: #0000ff; font-size: 13px"&gt;CType&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: 13px"&gt;(ReportID, Int64), ReportParameters)&lt;/span&gt;&lt;span style="color: #0000ff; font-size: 13px"&gt;&lt;span style="color: #0000ff; font-size: 13px"&gt; &lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: 13px"&gt;&lt;/span&gt;&lt;span style="color: #0000ff; font-size: 13px"&gt;&lt;span style="color: #0000ff; font-size: 13px"&gt;End&lt;/span&gt;&lt;/span&gt;&lt;span style="font-size: 13px"&gt; &lt;/span&gt;&lt;span style="color: #0000ff; font-size: 13px"&gt;&lt;span style="color: #0000ff; font-size: 13px"&gt;Function &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;</description></item></channel></rss>