Last post Jul 06, 2009 04:31 AM by Allen Chen – MSFT
Jul 01, 2009 11:01 AM|Disco Patrick|LINK
I recently posted
another thread in the Data Presentation Controls forum, though I think it might have got a better reponse in this forum.
I'm building a Custom Server Control so I can reuse it throughout my site wherever it is needed. Basically it emits a HTML table with header cells on the top and left. Inside the header cells there are titles. In the future there may also be other fields.
These fields should be editable.
The data cells also contain editable information, though this time it is a dropdown list that the user can choose from.
The control needs to initially show data that is already in the database, but then allow the user to edit and save any of the information back to the database.
I began this project by using User Controls for their relative simplicity, but soon discovered that it is (apparently) impossible to instantiate them from a class in my App_Code folder - they have to be instantiated from a page, or another User Control.
So I moved over to Custom Server Controls.
How it works so far: starting with a table, I use a typed dataset to get the column headings from the database, iterate through them, creating a new headercell for each one. I then get the row headings in a similar way, add a new row and header cell for
each one, and also add the data cells for each column. Every one of these cells is actually another Custom Control - as I create them, I set my custom properties to populate titles into textboxes, etc.
I thought there might be a standard way of rebinding any changes I made in these textboxes back to the database, but the one reply in my other thread would suggest not. I wanted to get a second opinion from this forum.
Perhaps the way forward is to simply add a submit button to the page, and get each of these cells to do something on postback. I've had a look at IPostBackEventHandler and IPostBackDataHandler but can't get my head around how they work. Can anyone help?
Jul 06, 2009 04:31 AM|Allen Chen – MSFT|LINK
I wrote a simple project that can help you understand IPostBackDataHandler: