Posts Tagged ‘gridview’
I ran into an interesting “problem” last week that wasn’t all that hard to figure out once I broke out the debugger. But I thought it would be useful to share the results to save others the time.
The situation was that I had an Object Data Source in a FormView that I wanted to share with both a DataGrid in the FormView and a DataRepeater outside of the FormView. Since it was in the FormView, the DataRepeater couldn’t see it.
So it seemed reasonable to me that if I could just trap the right event in the FormView I could assign the DataSource of the GridView to the DataSource of the Repeater, rebind the Repeater and we’d be on our way.
It wasn’t quite that simple.
Republished by Blog Post Promoter
A couple of days ago I mentioned a project that I’ve been working on that is a bit out of the ordinary as far as GridViews go. One of the issues I’ve had is that the edit template doesn’t map to the view template very well.
OK, it doesn’t map at all.
You see, the data that gets stored back to the database during the edit could go to two of four different tables. But the view is generated from a stored procedure that gathers the information from those tables and makes the result look like it came from one table.
So how do you have the GridView update the database under these conditions?
I don’t know about you, but I’ve had several occasions where I’ve needed to use the simplicity of the GridView control in ASP.NET. DataBinding, Paging, Sorting, etc. But I’ve also wanted to stack the information for a record in multiple rows.
Most of the time this happens when I need to display data that would take up two or three times as much of the width as my layout will allow.
The solution to this problem is quite simple: Use templated columns and Literal controls.
A couple of days ago I ran into a requirement to conditionally display footnote information at the bottom of a GridView display. We were already conditionally displaying icons in the row. What we needed to do was to conditionally show text at the bottom of the screen that explained what each icon was for. Here’s how we went about it.
I just saw a question about this yesterday and realized that while I know how to do this, not everyone does. So, here we go…
Here’s the problem. You want to be able to edit all of the rows in the gridview at once instead of having to switch to edit mode and save one row at the time. Normally, you’d want to do this when only a couple of items need to be changed per row and not the entire row’s worth of data.