Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / DataGrid / February 2007

Tip: Looking for answers? Try searching our database.

GridView.Rows empty on PostBack

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Doldrums - 01 Feb 2007 07:04 GMT
I have a GridView on my Asp.net page where I've added a TemplateField
that contains a CheckBox.

The idea is that a user can checkmark which records they want and then
click a "Submit" button.  I want to take action in the PostBack for the
records that they selected.

My problem is that on the PostBack the GridView.Rows.Count = 0.  Any
ideas how I am suppossed to read what checkboxes are checked?

-------

A little more information:
* AutoGenerateColumns="false".
* EnableSortingAndPagingCallbacks="false"... since I have a
TemplateField.
* I create the TemplateField in the aspx page.
* I create all other fields prior to DataBinding in the OnInit().
* GridView is bound to a SqlDataSource in the OnInit().
* I do NOT load or DataBind if the Page is a PostBack.
* Grid loads all the records fine when !Page.IsPostBack (44 Rows).
* I set a breakpoint in OnInit, PageLoad, and my Button_Click event.  
The Rows are always = 0.

I've tried removing the TemplateField and setting
EnableSortingAndPagingCallbacks="true"... but still no luck.

I'm hoping my brain is just fried and I am missing something simple!

PLEASE help.

Thanks,

Hugh O'Donnell
TiSch - 01 Feb 2007 13:08 GMT
On Feb 1, 8:04 am, Doldrums <no_spam_for_me_doldr...@odonnell.tv>
wrote:
> I have a GridView on my Asp.net page where I've added a TemplateField
> that contains a CheckBox.
[quoted text clipped - 30 lines]
>
> Hugh O'Donnell

Hi,
you could use javscript to write the id of the checked record into a
hiddenfield(comma separated).
Important: Use the onclick-Event not the onchange-Event because
ASP.NET generates a span and an input(type checkbox).
On codebehind you only have to read the hiddenfield to get the
selected records.

Regards,
Tim
Doldrums - 01 Feb 2007 14:54 GMT
> Hi,
> you could use javscript to write the id of the checked record into a
[quoted text clipped - 6 lines]
> Regards,
> Tim

Tim,

Thanks for the idea.  I have thought of that... but my spec requires no
JavaScript... so I'm looking for an aspx solution.

I believe I *should* be able to read back from the GridView on PostBack.

Hugh

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.