ASP.Net 2 Menu Control and MultiView Control
-
Hopefully somebody can help with this or at least tell me it is possible I have a VS 2005 project, the default page has a menu control, a multiview control and several views within this. When i click the menu item i use a case statement to make different views active, as shown;
protected void mnuMain_MenuItemClick(object sender, MenuEventArgs e) { string strMenu = ""; strMenu = mnuMain.SelectedValue.ToString(); try { switch (strMenu) { case "Home": MultiView1.SetActiveView(viewHome); break; case "Submit": MultiView1.SetActiveView(viewSubmit); break; case "System": ds = dba.ReturnDataSet("select * from system_status"); grdSystem.DataSource = ds; grdSystem.DataBind(); MultiView1.SetActiveView(viewSystem); break; default: MultiView1.SetActiveView(viewHome); break; } } catch (Exception exp) { string exception = exp.ToString().Replace("\n", ""); Response.Redirect("error.aspx?error=" + exception); } }
When the user clicks the menu item 'System' i want to connect to a database using a class i created called dba and the function ReturnDataSet. I then want to bind this to a gridview control called grdSystem, which is located in the View control 'System' and make this View the active view. This code complies and runs with no errors and the dataset has the correct number of rows returned. But the gridview inside the View is not displayed and on walking through the gridview has no items in it. (I tested with a gridView which was not inside a view and the contents as displayed ok so i think it is something to do with refreshing the view control??) Hopefully this makes sense and somebody can tell me if this is possible? Thanks Colin -- modified at 7:19 Tuesday 18th April, 2006 -
Hopefully somebody can help with this or at least tell me it is possible I have a VS 2005 project, the default page has a menu control, a multiview control and several views within this. When i click the menu item i use a case statement to make different views active, as shown;
protected void mnuMain_MenuItemClick(object sender, MenuEventArgs e) { string strMenu = ""; strMenu = mnuMain.SelectedValue.ToString(); try { switch (strMenu) { case "Home": MultiView1.SetActiveView(viewHome); break; case "Submit": MultiView1.SetActiveView(viewSubmit); break; case "System": ds = dba.ReturnDataSet("select * from system_status"); grdSystem.DataSource = ds; grdSystem.DataBind(); MultiView1.SetActiveView(viewSystem); break; default: MultiView1.SetActiveView(viewHome); break; } } catch (Exception exp) { string exception = exp.ToString().Replace("\n", ""); Response.Redirect("error.aspx?error=" + exception); } }
When the user clicks the menu item 'System' i want to connect to a database using a class i created called dba and the function ReturnDataSet. I then want to bind this to a gridview control called grdSystem, which is located in the View control 'System' and make this View the active view. This code complies and runs with no errors and the dataset has the correct number of rows returned. But the gridview inside the View is not displayed and on walking through the gridview has no items in it. (I tested with a gridView which was not inside a view and the contents as displayed ok so i think it is something to do with refreshing the view control??) Hopefully this makes sense and somebody can tell me if this is possible? Thanks Colin -- modified at 7:19 Tuesday 18th April, 2006 -
Have you tried to place text or another simple control like Label along with the GridView in the System view and see if the active view is actually refreshed?
I can update the text propery of a label just after I do the bind and it shows the update. I can also add all the items in the dataSET to a dropdownlist and it shows. It is just the gridView which does not show the update - as if the bind has not worked. Thanks Colin
-
I can update the text propery of a label just after I do the bind and it shows the update. I can also add all the items in the dataSET to a dropdownlist and it shows. It is just the gridView which does not show the update - as if the bind has not worked. Thanks Colin
-
Hmm, is there any chance that the Grid control is rebound somewhere else in the web page? Here on my machine, I simply have two view with one containing a GridView control, every time I switch to that view I can see the gridview control displayed.
not sure what was going wrong but re-created the grid view and binding was succesfull GridView is displayed as expected Thanks Colin