0
votes

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);



}
1
Dublicate by the same user : stackoverflow.com/questions/1465053/… - Canavar

1 Answers

2
votes

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.