iterate through bound columns

Discussion in 'ASP .Net Datagrid Control' started by Svetlin Grancharov, Sep 28, 2003.

  1. Use DataGridColumn instead of BoundColumn. So the code
    should be:

    dim bc as DataGridColumn
    for each bc in myGrid.Columns
    ...
    After that depends on column (some could be BoundColumn,
    some TemplateColumn) you can read headings and data column
    names.

    Svetlin Grancharov

    >-----Original Message-----
    >Hello,
    >
    >I have several pages with datagrids, and I was thinking

    of writing a common
    >excel function.
    >
    >I want to iterate through the columns of each datagrid to

    pick off the
    >headings and data column names.
    >
    >The datagrids may include template columns, so if I do

    this:
    >
    > dim bc as BoundColumn
    > for each bc in myGrid.Columns
    > ...
    >
    >it'll raise an error when it hits the template column.
    >
    >I saw a post about going through the items collection of

    the datagrid, but I
    >wasn't sure how
    >to do this.
    >
    >JC
    >
    >
    >
    >
    >.
    >
     
    Svetlin Grancharov, Sep 28, 2003
    #1
    1. Advertising

  2. Svetlin Grancharov

    jim corey Guest

    Well at this point I don't know how to figure out what kind of column bc is.
    Do I use bc.GetType?
    Any example appreciated.

    "Svetlin Grancharov" <> wrote in message news:<0ecd01c3859a$8fee1af0$>...
    > Use DataGridColumn instead of BoundColumn. So the code
    > should be:
    >
    > dim bc as DataGridColumn
    > for each bc in myGrid.Columns
    > ...
    > After that depends on column (some could be BoundColumn,
    > some TemplateColumn) you can read headings and data column
    > names.
    >
    > Svetlin Grancharov
    >
    > >-----Original Message-----
    > >Hello,
    > >
    > >I have several pages with datagrids, and I was thinking

    > of writing a common
    > >excel function.
    > >
    > >I want to iterate through the columns of each datagrid to

    > pick off the
    > >headings and data column names.
    > >
    > >The datagrids may include template columns, so if I do

    > this:
    > >
    > > dim bc as BoundColumn
    > > for each bc in myGrid.Columns
    > > ...
    > >
    > >it'll raise an error when it hits the template column.
    > >
    > >I saw a post about going through the items collection of

    > the datagrid, but I
    > >wasn't sure how
    > >to do this.
    > >
    > >JC
    > >
    > >
    > >
    > >
    > >.
    > >
     
    jim corey, Sep 29, 2003
    #2
    1. Advertising

  3. Yes you can use GetType().ToString() and after that to
    look in this string but better is would be:
    ....
    Dim dgc As DataGridColumn
    Dim bc As ButtonColumn
    dim tc as TemplateColumn
    ....
    For Each dgc In myGrid.Columns
    If TypeOf dgc Is ButtonColumn Then
    bc = dgc
    ...
    end if
    ...
    If TypeOf dgc Is TemplateColumn Then
    tc = dgc
    ...
    end if
    ...
    Next


    Best

    Svetlin Grancharov

    >-----Original Message-----
    >Well at this point I don't know how to figure out what

    kind of column bc is.
    >Do I use bc.GetType?
    >Any example appreciated.
    >
    >"Svetlin Grancharov" <> wrote in

    message news:<0ecd01c3859a$8fee1af0$>...
    >> Use DataGridColumn instead of BoundColumn. So the code
    >> should be:
    >>
    >> dim bc as DataGridColumn
    >> for each bc in myGrid.Columns
    >> ...
    >> After that depends on column (some could be

    BoundColumn,
    >> some TemplateColumn) you can read headings and data

    column
    >> names.
    >>
    >> Svetlin Grancharov
    >>
    >> >-----Original Message-----
    >> >Hello,
    >> >
    >> >I have several pages with datagrids, and I was

    thinking
    >> of writing a common
    >> >excel function.
    >> >
    >> >I want to iterate through the columns of each datagrid

    to
    >> pick off the
    >> >headings and data column names.
    >> >
    >> >The datagrids may include template columns, so if I do

    >> this:
    >> >
    >> > dim bc as BoundColumn
    >> > for each bc in myGrid.Columns
    >> > ...
    >> >
    >> >it'll raise an error when it hits the template column.
    >> >
    >> >I saw a post about going through the items collection

    of
    >> the datagrid, but I
    >> >wasn't sure how
    >> >to do this.
    >> >
    >> >JC
    >> >
    >> >
    >> >
    >> >
    >> >.
    >> >

    >.
    >
     
    Svetlin Grancharov, Sep 30, 2003
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Gogo
    Replies:
    1
    Views:
    2,140
    Sudsy
    Sep 4, 2003
  2. sunil panda

    Lower bound & Upper bound

    sunil panda, Dec 25, 2003, in forum: Java
    Replies:
    9
    Views:
    7,355
    thushara wijeratna
    Oct 7, 2008
  3. runescience
    Replies:
    0
    Views:
    1,494
    runescience
    Feb 9, 2006
  4. John
    Replies:
    4
    Views:
    958
    RedGrittyBrick
    Apr 1, 2008
  5. Vinki

    template columns and bound columns in gridview

    Vinki, Apr 25, 2007, in forum: ASP .Net Web Controls
    Replies:
    2
    Views:
    921
    Vinki
    Apr 25, 2007
Loading...

Share This Page