Using System;
Using System. Collections;
Using System. Configuration;
Using System. Data;
Using System. Linq;
Using System. Web;
Using System. Web. Security;
Using System. Web. UI;
Using System. Web. UI. HtmlControls;
Using System. Web. UI. WebControls;
Using System. Web. UI. WebControls. WebParts;
Using System. Xml. Linq;
Using System. Configuration;
Using System. Data. SqlClient;
Public partial class nextclassid: System. Web. UI. Page
{
Protected static string connectionString = ConfigurationManager. receivettings ["ConnStr"]. ToString ();
Protected void Page_Load (object sender, EventArgs e)
{
Int classid = Convert. ToInt32 (Request. QueryString ["id"]);
DataList1.DataSource = GetListClass (classid );
DataList1.DataBind ();
}
Public DataTable GetListClass (int ClassId)
{
SqlConnection Conn = new SqlConnection (connectionString );
Conn. Open ();
SqlDataAdapter sda = new SqlDataAdapter ();
Sda. SelectCommand = new SqlCommand ("select * from ArticleClass", Conn );
// DataSet ds = new DataSet ();
// Sda. Fill (ds, "ArticleClass ");
// DataTable DT = new DataTable ();
// DT = (DataTable) ds. Tables ["ArticleClass"];
DataTable DT = new DataTable ();
Sda. Fill (DT );
DataRow myrow;
DataTable mytab = new DataTable ();
Mytab. Columns. Add ("Id ");
Mytab. Columns. Add ("Title ");
Mytab. Clear ();
For (int I = 0; I <DT. Rows. Count; I ++)
{
If (ClassId = (int) DT. Rows [I] ["ParentId"])
{
Myrow = mytab. NewRow ();
Myrow [0] = DT. Rows [I] ["Id"];
Myrow [1] = DT. Rows [I] ["Title"];
Mytab. Rows. Add (myrow );
Myrow. AcceptChanges ();
}
}
If (mytab. Rows. Count = 0) mytab = GetListClass (0 );
Return mytab;
}
}