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. Advertising

  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. 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. Dexter
    Replies:
    1
    Views:
    416
    Eliyahu Goldin
    Jan 18, 2005
  2. Ken Varn
    Replies:
    1
    Views:
    974
    Ken Varn
    Aug 19, 2005
  3. Alex
    Replies:
    2
    Views:
    1,218
  4. Replies:
    26
    Views:
    2,107
    Roland Pibinger
    Sep 1, 2006
  5. cinsk
    Replies:
    35
    Views:
    2,593
    James Kanze
    Oct 11, 2010
Loading...

Share This Page