public void Page_Load(object sender,EventArgs e)
{
if(!IsPostBack)
DataListDataBind();
}
public void DataListDataBind()
{
SqlConnection myconn=new SqlConnection(ConfigurationSettings.AppSettings["connectionstring"].ToString());
SqlDataAdapter da=new SqlDataAdapter("select BigClass_id,BigClass_name from BigClass",myconn);
DataTable mytable=new DataTable();
try
{
da.Fill(mytable);
ArrayList nameList = new ArrayList();
for(int i=0;i<mytable.Rows.Count;i++)
{
nameList.Add("|--"+mytable.Rows[i]["BigClass_name"].ToString());
string id=mytable.Rows[i]["BigClass_id"].ToString();
SqlConnection myconn1=new SqlConnection(ConfigurationSettings.AppSettings["connectionstring"].ToString());
SqlDataAdapter da1=new SqlDataAdapter("select SmalClass_name from SmalClass where BigClass_id='"+id+"'",myconn1);
DataTable mytable1=new DataTable();
da1.Fill(mytable1);
for(int j=0;j<mytable1.Rows.Count;j++)
nameList.Add("*******"+mytable1.Rows[j]["SmalClass_name"].ToString());
}
Drop1.DataSource=nameList;
Drop1.DataBind();
}
catch(Exception error)
{
Response.Write(error.ToString());
}
}