copy a template column

Discussion in 'ASP .Net' started by =?Utf-8?B?bG91aXNlIHJhaXNiZWNr?=, Sep 1, 2005.

  1. This sounds complicated but bear with me. I have a datagrid. It is dynamic in
    that, i dont know how many columns i will have until the dataset is back so i
    have to build the datagrid dynamically. I know there will be at least one
    column required however, so I have put into my aspx a template column with a
    checkbox in it. Then for the number of columns in my dataset more than 1 I
    want to copy that templatecolumn and duplicate it for the amount of columns
    remaining in the dataset. all columns have the same checkbox in it and is
    identical to the one I have written in the aspx, but the column headertext is
    diff etc. the reason i do it this way is because i need to put an event in
    the oncheck of the tickbox and i cannot easily dynamically set this in server
    code (has to initialise before databind etc believe me i've tried).

    e.g. my dataset returns 5 columns. i bind the first column to my datagrid
    column 1. Then I want to duplicate this templatecolumn x 4 grabbing values of
    the corresponding dataset column as I go. Does that make sense?

    I cant find a way to copy a template column, and all of its child controls.

    any help appreciated. thanks.
     
    =?Utf-8?B?bG91aXNlIHJhaXNiZWNr?=, Sep 1, 2005
    #1
    1. Advertisements

  2. Hi Louise,

    You can inherit from ITemplate to create your own customized
    DataGridTemplate. This example has a demonstration of how to create a
    customized template for the DataGrid:
    http://www.societopia.net/Samples/DataGridEventDelegates.aspx

    HTH,
    Phillip Williams
    http://www.societopia.net
    http://www.webswapp.com


    "louise raisbeck" wrote:

    > This sounds complicated but bear with me. I have a datagrid. It is dynamic in
    > that, i dont know how many columns i will have until the dataset is back so i
    > have to build the datagrid dynamically. I know there will be at least one
    > column required however, so I have put into my aspx a template column with a
    > checkbox in it. Then for the number of columns in my dataset more than 1 I
    > want to copy that templatecolumn and duplicate it for the amount of columns
    > remaining in the dataset. all columns have the same checkbox in it and is
    > identical to the one I have written in the aspx, but the column headertext is
    > diff etc. the reason i do it this way is because i need to put an event in
    > the oncheck of the tickbox and i cannot easily dynamically set this in server
    > code (has to initialise before databind etc believe me i've tried).
    >
    > e.g. my dataset returns 5 columns. i bind the first column to my datagrid
    > column 1. Then I want to duplicate this templatecolumn x 4 grabbing values of
    > the corresponding dataset column as I go. Does that make sense?
    >
    > I cant find a way to copy a template column, and all of its child controls.
    >
    > any help appreciated. thanks.
     
    =?Utf-8?B?UGhpbGxpcCBXaWxsaWFtcw==?=, Sep 2, 2005
    #2
    1. Advertisements

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. Dexter
    Replies:
    1
    Views:
    543
    Eliyahu Goldin
    Jan 18, 2005
  2. Ken Varn
    Replies:
    1
    Views:
    1,093
    Ken Varn
    Aug 19, 2005
  3. Charleees
    Replies:
    2
    Views:
    8,499
    Eliyahu Goldin
    Jun 20, 2006
  4. Alex
    Replies:
    2
    Views:
    1,583
  5. Replies:
    26
    Views:
    2,541
    Roland Pibinger
    Sep 1, 2006
  6. cinsk
    Replies:
    35
    Views:
    3,134
    James Kanze
    Oct 11, 2010
  7. Ravichandran Mahalingam

    Bound Column or Template Column (w dAdapater?) in DataGrid

    Ravichandran Mahalingam, Jan 9, 2004, in forum: ASP .Net Datagrid Control
    Replies:
    0
    Views:
    376
    Ravichandran Mahalingam
    Jan 9, 2004
  8. Esperanza

    Template column base on another column value

    Esperanza, Feb 18, 2005, in forum: ASP .Net Datagrid Control
    Replies:
    5
    Views:
    321
    Elton Wang
    Feb 21, 2005
Loading...