Asp.net traverses all keys and values in a node of the configuration file and binds them to the gridview.
Helper app_helper = new helper ();
Dataset DS = new dataset ();
Datatable dt = new datatable ();
Protected void page_load (Object sender, eventargs E)
{
Gvwbind ();
}
# Region bind the gridview
/// <Summary>
/// Bind the gridview
/// </Summary>
Protected void gvwbind ()
{
INI. inipath iniinipath = new ini. inipath ();
INI. INIFILE iniinifile = new ini. INIFILE (iniinipath. getinipath ());
String foldernames = app_helper.getallfolder (server. mappath ("http://www.cnblogs.com/APPDIR"); // obtain the names of all subfolders in the appdir folder
String [] Foldername = new string [foldernames. Split (','). Length-1]; // declare an array to save the absolute path of the folder
Foldername = foldernames. Split (','); // assign a value to the absolute path array of the folder.
DT. Columns. Add ("lkname", typeof (string ));
DT. Columns. Add ("qdjsjm", typeof (string ));
DT. Columns. Add ("qdipdz", typeof (string ));
For (INT I = 0; I <Foldername. Length-1; I ++)
{
Datarow ROW = DT. newrow ();
Foldername [I] = Foldername [I]. substring (Foldername [I]. lastindexof ('\') + 1); // capture the folder name
Row ["lkname"] = Foldername [I]; // assign a value to the lkname character
If (! Iniinifile. inireadvalue ("dzjclkzp", Foldername [I]). Equals ("") // check whether the key with the same folder name exists in the configuration file
{
Row ["qdjsjm"] = iniinifile. inireadvalue ("dzjclkzp", Foldername [I]). Split (',') [0]; // assign a value to the qdjsjm Field
Row ["qdipdz"] = iniinifile. inireadvalue ("dzjclkzp", Foldername [I]). Split (',') [1]; // assign a value to the qdipdz Field
}
DT. Rows. Add (ROW );
}
Gvwgkwh. datasource = DT; // bind to an array
Gvwgkwh. databind (); fashion Java-JavaScript mogujie.com women's clothing
}
# Bind endregion to the gridview