locked
need to set properties on run time created control RRS feed

  • Question

  • User-847567857 posted

    I have datasources being created in the code behind, and I am using an int for the name like:

    i=1

    createdatasource

    datasource(i) 

    i=i+1

    next



    How do I define properties on a dynamic control like that?

    datasource(convert.tostring(i)).connectionstring = "xx" 

    that will not work, how do I set properties on a dynamic control?

    Wednesday, December 29, 2010 2:09 AM

Answers

  • User-821857111 posted

    gridview(i).DataSource=dt

    Just like that.



    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, December 29, 2010 3:19 AM

All replies

  • User-821857111 posted

    DataSource controls are not meant to be instantiated in code. Why don't you simply instantiate an ADO.NET Command object instead?


    Wednesday, December 29, 2010 2:18 AM
  • User-847567857 posted

    well I could fill data tables and bind to those, but the fact still remains...


    how would I set

    gridview(i).DataSource=dt


    ??

    Wednesday, December 29, 2010 2:46 AM
  • User-821857111 posted

    gridview(i).DataSource=dt

    Just like that.



    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Wednesday, December 29, 2010 3:19 AM