| 0. | private void smCountries_GroupDataBound(object sender, SlidingMenuGroupEventArgs e) |
| 1. | { |
| 2. | | DataTableCollection dtcDataSource = (DataTableCollection)smCountries.DataSource; |
| 3. | | //this eventhandler run once for each DataTable in the DataTableCollection DataSource, therefore there is a current DataTable |
| 4. | | DataTable dtCurrent = dtcDataSource[e.GroupIndex]; |
| 5. | |
| 6. | | Label lblContinent = (Label)e.GroupHeader.FindControl("lblContinent"); |
| 7. | | DataGrid dgCountry = (DataGrid)e.GroupCanvas.FindControl("dgCountry"); |
| 8. | |
| 9. | | lblContinent.Text = (string)dtCurrent.Rows[0]["continent"]; //continent exists for all rows, I just choose arbitrary row number 1 |
| 10. | | //Bind the DataGrid within the current GroupCanvas to the current DataTable |
| 11. | | dgCountry.DataSource = dtCurrent; |
| 12. | | //delegate the ItemDatabound event to the function dgCountry_ItemDataBound |
| 13. | | dgCountry.ItemDataBound += new DataGridItemEventHandler(dgCountry_ItemDataBound); |
| 14. | | //call dgCountry_ItemDataBound for each DataRow within the DataTable DataSource by invoking DataBind() |
| 15. | | dgCountry.DataBind(); |
| 16. | |
| 17. | | //Here I mainly secure that the colors of some of the SlidingMenu elements corresponds to the color on the image map |
| 18. | | string currentColor = String.Empty; |
| 19. | | switch (lblContinent.Text) |
| 20. | | { |
| 21. | | | case "North America" : |
| 22. | | | | currentColor = "#000066"; |
| 23. | | | | break; |
| 24. | | | case "South America" : |
| 25. | | | | currentColor = "#990033"; |
| 26. | | | | break; |
| 27. | | | case "Africa" : |
| 28. | | | | currentColor = "#996600"; |
| 29. | | | | //if the current Group is the Group that shows Africa then open that Group at page load |
| 30. | | | | e.GroupHeader.GroupHeaderStyles.OpenThisGroupAtStartup = true; |
| 31. | | | | break; |
| 32. | | | case "Asia" : |
| 33. | | | | currentColor = "#CC9933"; |
| 34. | | | | break; |
| 35. | | | case "Australia & Oceania" : |
| 36. | | | | currentColor = "#993333"; |
| 37. | | | | break; |
| 38. | | | case "Europe" : |
| 39. | | | | currentColor = "#006666"; |
| 40. | | | | break; |
| 41. | | } |
| 42. | | e.GroupHeader.GroupHeaderStyles.BackgroundColor = currentColor; |
| 43. | | e.GroupCanvas.GroupCanvasStyles.ScrollbarFaceColor = currentColor; |
| 44. | } |