aspalliance.com: ASP.NET 2.0, .
" , , , ASP.NET 2.0. , , ".
:
protected void LoadData()
{
DataSet ds = new DataSet();
string connStr = YOUR_CONNECTION_STRING_HERE;
using(SqlConnection conn = newSqlConnection(connStr))
{
string sql = "Select NodeID, Caption, Url, ParentID from Menu";
SqlDataAdapter da = newSqlDataAdapter(sql, conn);
da.Fill(ds);
da.Dispose();
}
ds.DataSetName = "Menus";
ds.Tables[0].TableName = "Menu";
DataRelation relation = newDataRelation("ParentChild",
ds.Tables["Menu"].Columns["NodeID"],
ds.Tables["Menu"].Columns["ParentID"], true);
relation.Nested = true;
ds.Relations.Add(relation);
xmlDataSource.Data = ds.GetXml();
}