Surya sasidhar
Surya sasidhar

Reputation: 30293

dynamic controls in asp.net

in my application i want to create dynamic datalist i created but it is not displaying this is my code help me please, thank u.

protected void btn_Click(object sender, EventArgs e) {

    DataList datlst = new DataList();
    datlst.ID = "mydatalist";
    da = new SqlDataAdapter("select emname from emp", con);
    ds = new DataSet();
    da.Fill(ds, "emp");

    datlst.DataSource = ds.Tables[0];
    datlst.DataBind();

    //this.Controls.Add(datlst);
   form1.Controls.Add(datlst);



}

Upvotes: 0

Views: 111

Answers (1)

Himadri
Himadri

Reputation: 8876

You have to set Itemtemplate for the datalist where the data will be bound. Please review this link to create itemtemplate from code behind

Please check if it can help.

Upvotes: 2

Related Questions