| 0. | namespace YourNamespace |
| 1. | { |
| 2. | | public class YourClass : System.Web.UI.Page |
| 3. | | { |
| 4. | | | protected Webmodelling.Controls.Menues.SlidingMenu smSlidingDataSetInViewMode; |
| 5. | | | private DataSet mdsNorthwind; |
| 6. | | |
| 7. | | | private void Page_Load(object sender, System.EventArgs e) |
| 8. | | | { |
| 9. | | | | mdsNorthwind = new DataSet(); |
| 10. | |
| 11. | | | | string appl_physical_path = Request.PhysicalApplicationPath; |
| 12. | | | | if (!appl_physical_path.EndsWith("\\")){appl_physical_path = appl_physical_path + "\\";} //old habit, sorry |
| 13. | | | | string physicalPath_Northwind = appl_physical_path + @"Data\Northwind.mdb"; |
| 14. | | | | string connectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + physicalPath_Northwind; |
| 15. | |
| 16. | | | | OleDbDataAdapter objDataAdapter = new OleDbDataAdapter(new OleDbCommand()); |
| 17. | | | | objDataAdapter.SelectCommand.Connection = new OleDbConnection(connectionString); |
| 18. | | | | objDataAdapter.SelectCommand.Connection.Open(); |
| 19. | |
| 20. | | | | string sqlCategories = "SELECT TOP 10 * FROM Categories"; |
| 21. | | | | objDataAdapter.SelectCommand.CommandText = sqlCategories; |
| 22. | | | | objDataAdapter.Fill(mdsNorthwind, "Categories"); |
| 23. | | | | |
| 24. | | | | ... fetching the rest of the of the tables ... |
| 25. | |
| 26. | | | | objDataAdapter.SelectCommand.Connection.Close(); |
| 27. | |
| 28. | | | | //The DataSource can be any IEnumerable, therefore also a DataTableCollection |
| 29. | | | | smSlidingDataSetInViewMode.DataSource = mdsNorthwind.Tables; |
| 30. | | | | //Delegate the GroupDataBound event to the smSlidingDataSetInViewMode_GroupDataBound function |
| 31. | | | | smSlidingDataSetInViewMode.GroupDataBound += new SlidingMenuGroupEventHandler(smSlidingDataSetInViewMode_GroupDataBound); |
| 32. | | | | //Raise the GroupDataBound event for each item (DataTable) in the Datasource (DataTableCollection) |
| 33. | | | | smSlidingDataSetInViewMode.DataBind(); |
| 34. | | | } |
| 35. | |
| 36. | | | private void smSlidingDataSetInViewMode_GroupDataBound(object sender, Webmodelling.Controls.Menues.SlidingMenuGroupEventArgs e) |
| 37. | | | { |
| 38. | | | | DataTableCollection dataSource = (DataTableCollection)smSlidingDataSetInViewMode.DataSource; |
| 39. | | | | DataTable dtCurrent = dataSource[e.GroupIndex]; //e.GroupIndex is used the same way as you normally use e.Item.ItemIndex |
| 40. | |
| 41. | | | | Label lblTableName = (Label)e.GroupHeader.FindControl("lblTableName"); //normally you write e.Item.FindControl, however the SlidingMenu is a slightly more complex dividing the item (Group) into a GroupHeader and a GroupCanvas |
| 42. | | | | System.Web.UI.WebControls.Image imgMagnifier = (System.Web.UI.WebControls.Image)e.GroupHeader.FindControl("imgMagnifier"); |
| 43. | | | | DataGrid dgTable = (DataGrid)e.GroupCanvas.FindControl("dgTable"); |
| 44. | |
| 45. | | | | lblTableName.Text = dtCurrent.TableName; |
| 46. | | | | //I postfixed the magnifier images with the numbers 1 to 8 corresponding to the GroupIndex (however the GroupIndex is zero indexed) |
| 47. | | | | imgMagnifier.ImageUrl = "/images/slidingmenu/example_SlidingMenuInViewMode/magnifier_w175h200_0" + (e.GroupIndex + 1) + ".gif"; |
| 48. | | | | //in the current canvas I here write out the current DataTable using a DataGrid (there are just as many GroupCanvas as there are Tables in the DataTableCollection datasource (as there are tables in Northwind.mdb)). |
| 49. | | | | dgTable.DataSource = dtCurrent; |
| 50. | | | | dgTable.DataBind(); |
| 51. | | | } |
| 52. | | } |
| 53. | } |