How to do 'real' inline editing in GridView

C

cpnet

I have a GridView which I'm populating from an ObjectDataSource (give the
GridView a DataTable). The GridView will have about 20 rows, and only one
editable column. The editable column consists of a RadioButtonList ("Yes",
"No", "Not Answered") in a TemplateColumn. I want the user to be able to
select a radio button for each row in the GridView (without having to first
put each row into edit mode). Once the user has selected the Radio button
for each row, they'll post back the form and I want the values from the
radio buttons persisted back to my source DataTable.

The GridView doesn't seem to fire it's RowUpdate/Edit events unless I
actually put one of the rows into edit mode. If I cause a post-back, the
radio button selections are persisted (I guess in the View State) but those
selections don't get pushed through to my ObjectDataSource (it's assigned
update method is not called). It seems the Grid View is not set up to
automatically do 'true' inline editing where you can edit multiple rows in a
single postback. Is there an event of the GridView I can/should use to
persist the selections to my ObjectDataSource's DataTable?
 
W

Walter Wang [MSFT]

Hi cpnet,

Happy New Year!

Based on my understanding, your requirement can be achieved using a
customized GridView that supports Bulk Editing:

#Matt Dotson's .NET Tips & Tricks : Real World GridView: Bulk Editing
http://blogs.msdn.com/mattdotson/articles/490868.aspx

Using this enhanced GridView control, the rows will all be set to editing
mode, when the Save() method gets called, they will all be saved to the
backend data source. This might be a little different to your original
requirement as you want to postback on every change of the RadioButtonList.
From the performance point of view, I would recommend you to use this batch
updating approach, user will be able to make the changes to all the rows
they're interested, and when a Save button is clicked, all the changes can
be saved in one postback.

To track which controls user has made modification, the control needs a
customized BoundField class to work with various controls. Currently it
doesn't have support for RadioButtonList, but I think this should be easy
to add support for it since it's similar to the DropDownList. Please refer
to the DropDownField class for more information. Please feel free to let me
know if you have questions while adding RadioButtonList to it.


Sincerely,
Walter Wang ([email protected], remove 'online.')
Microsoft Online Community Support

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications. If you are using Outlook Express, please make sure you clear the
check box "Tools/Options/Read: Get 300 headers at a time" to see your reply
promptly.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.
 
C

cpnet

Hi Walter,

I actually found Matt's article a couple of days ago, and this is what I
implemented. (Except I'm only always dealing with 17 rows of data, so I
always just update them all without bothering to check which ones actually
need updating).

Thanks,
cpnet
 
W

Walter Wang [MSFT]

Hi cpnet,

Thanks for the update. Let me know if have any other questions.

Regards,
Walter Wang ([email protected], remove 'online.')
Microsoft Online Community Support

==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,969
Messages
2,570,161
Members
46,705
Latest member
Stefkari24

Latest Threads

Top