Skip to content

Dynamic generation of controls

sunil yarragogu

Asked Nov 22, 2007, 6:38 PM EST1 answer
Share
LinkedInX
I have to generate a page  with dynamic controls with data coming from database.Depending upon control type coming from database i have to create a control in the web page and assign value to it which comes from database. web control values also comes from database.Could any body can help me in this.

1 Answer

Know the answer? Post it. Somebody with the same question will find it here.

  • 0

    See the below code to create controls dynamically -

    Suppose you need to create TextBox 

    TextBox t = new TextBox();

    Get the value from the database and assign it

    t.Text = "abcd";

    some other examples -

    DataGrid dg = new DataGrid();

    DataGridView dgv = new DataGridView();

    0