Friday, June 11, 2004

.Stories of a .NET Newbie (2)

And the story continues...:

1) I tweaked the web.config settings a little bit, more precisely in the authentication section. Immediately the IDE came up with a big Microsoft Development Environment "Error while trying to run project.. etc" and mumbling on for a couple sentences about all kinds of things not being OK. Me knowing I only changed some lines in the web.config, pressed Ctrl-Z until I was back from where I started, and everything was OK. Then I realized you can watch the web.config -being an XML file- in 'xml' mode and in 'data' mode. Now I know I should, after changing something here, first check data mode to see whether we're speaking well formed XML here. The 'data' mode will tell you did. Or is there a better way. I don't see any options to further kind of debug the web.config file?
Anyway, be careful with your brackets here.

2) Wow, I thought: .NET does data paging automatically now. Let me just put this DataGrid1 on my Form, set AllowPaging to True and PageSize to 5; run it!. Well, another .NET error popped up telling me "System.Web.HttpException: Control 'DataGrid1__ctl9__ctl1' of type 'DataGridLinkButton' must be placed inside a form tag with runat=server."
The funny thing is that the datagrid pulled it's data from the SQL Server with no problems without paging. So I wouldn't expect an error like this. But well, the message is actually quite clear, so it should be fixed in a sec. So I switched over to 'html' view to see that the DataGrid was automatically placed in a Web Form already present on the page. So cut-n-paste it out of here, surround it with some form tags <form runat=server> and there you go. Only, what happens next is that I have page one with records 1-5, and clicking the 'next' doesn't yield records 6-10 which are clearly present in the table. The page refreshes only to come up with the same 5 records again, and no error message.
What to do now? This desperately calls for an event handler. But after having added some code to the DataGrid1_PageIndexChanged Sub in which the PageIndexChanged property decides to load a NewPageIndex, the Grid disappears from my screen when going the second page. Hmm... do I go on on this path, or am I heading in the wrong direction, meaning I should stop and start again from scratch? This is oftentimes a difficult desision to make for me. Well, I'm stopping this entry now 'cause I have to fix something and don't want to bore you with more of these details which are surely quite uninteresting to you, o highly experienced .NET developer.