r/ASPNET • • Mar 03 '11
Need help with rendering table in multiview control
hey everyone,
so this is gonna be a long post, so please bear with me. I'm working on a school project where my group & I are building a calendar web app for an organization using ASP.NET & C#. All of us were new to this framework going into the project, but we've all learned a lot so far.
I've been tasked with implementing tabs in one of our pages (specifically, an administrative page where admins can approve, disapprove, and edit user-submitted dates for the calendar as well as choose a theme for each month). In order to implement the tabs, I think using the UpdatePanel & MultiView web controls are the way to go. At the moment, I have multiple View controls nested within the MultiView control, which is nested inside the ContentTemplate tag, which is finally nested within the UpdatePanel control. So starting from the inside heading towards the outmost controls: View -> MultiView -> ContentTemplate -> UpdatePanel.
Now, I've seen plenty of examples where you have different kinds of content within individual View controls; most are just text or another ASP.NET control (e.g. a Button). However, I need the aforementioned table to show up in one of the tabs. the problem is that the table is created in a method that is only ever called within the Page_Load function/method (which is only triggered when a page loads). So the table is loading once, and never again.
Furthermore, I didn't write all the code-behind stuff or HTML, but I did see a DIV element labeled "TableDiv", and I thought that by moving this DIV within the first View control, the Table might render only when that View is active. Unfortunately, it didn't do anything
Maybe I should call the individual method that creates the table using the individual View? I'm not sure....I've been at this for a while, so any help would be greatly appreciated!
thanks,
--Jonathan
EDIT: Also, if you notice I'm wrong in my understanding of ASP.NET/C#, please point it out to me. I'm still a newbie to this framework, so I know I still have a lot to learn...thanks.
View all comments
Show parent comment
1
u/MondoHawkins Mar 03 '11
So you said that function is being called when the Page_Load delegate fires. What's not clear from your original post is what's happening in browser that indicates when the table should be reloaded or why it's disappearing. I suspect that one of your button click events is firing and you're expecting the table to update accordingly? (btw, no event handler is being added to your delete buttons.)
One style note: Event_Date is not the standard style of naming classes in .net. There's an almost unanimous collective agreement amongst .net developers that class names should be declared using Pascal case where the first letter of each word is capitalized (eg. EventDate).
Also, though this method of manually building the table in code works, it's ignoring one of the biggest benefits that Web Forms framework gave us, namely data binding. You could have done a lot of what you're doing manually with much less code by using the DataGrid. (Double check that I named the right control here. I've been developing with the MVC framework for almost a year now. GridView might be the control I'm thinking of.)