Another DataGrid with DataList's nesting - better way [original]

xiaoxiao2021-03-05  23

Compared to the previous use of the shortcomings: 1. It is not possible to limit the number of records returned; 2. It is inconvenient to the bond, and it is not possible to order; 3. Simple program, but it is not easy to understand. 4. It is possible to not be easily implemented for the three or more nestings. The nested solution given this time is very easy to understand, which is easy to understand. And solve the above four problems.

The following is the main code: <% # DataBinder.Eval ( Container.DataItem, "NavigatorID")%> @ <% # databinder.eval (container.dataitem, "nodecaption")%>


<

ItemStyle HorizontalAlign = Left CssClass = "nav"> private void DList_Class_ItemDataBound (object sender, System.Web.UI.WebControls.DataListItemEventArgs e) {if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem) {DataGrid dg = (DataGrid) e.Item.FindControl ( "DG_SubClass"); string itemIndex = this.DList_Class.DataKeys [e.Item.ItemIndex]. Tostring ();

string [] strSqlArray = new string [3] { "select Top 10 IOrder, ILevel, IParentID, NavigatorID, NodeCaption, ModuleID, ModuleType from NavigatorNodes where IParentID in (", itemIndex, ");"}; string strSql = string.Concat STRSQLARRAY; String Tablename = "Subclass" itemindex;

This.dbclass.adapterfill (DS, CommandType.Text, Strsql, TableName, New OledbParameter [0]);

Dg.itemdatabase = new system.web.ui.webcontrols.dataGriditeMeventHandler (this.dg_subclass_itemdatabase;

DG.DataSource = DS.TABLES [TABLENAME] .defaultView; Dg.Database ();}} ==================== More content, welcome to visit ms.mblogger .cn / nono

转载请注明原文地址:https://www.9cbs.com/read-34911.html

New Post(0)