473,386 Members | 1,864 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Problem "seeing" unbound checkboxes in nested gridview

I have unbound checkboxes in a nested gridview to allow multi-selection of "child" rows. For context, the parent gridview rows are for large "reports", the child rows are for various specific files comprising each report. I want the user to be able to select an arbitrary collection of report files and have them emailed by clicking an "Email selected files" button.

Everything displays properly, including the checkboxes for each child row (each file), but on postback (after clicking the "Email selected files" button), I cannot "see" any child rows when iterating through the rows of the parent gridview. What's odd is that I can see the nested (child) gridview as a GridView object that has the correct number of columns, the correct column headings, the correct DataSourceID, etc..., but this nested gridview's rowcount is always zero.

I have read lots of posts on how to create nested gridviews, and that doesn't seem to be the problem. I am setting the nested gridview's datasource in the parent gridview's RowDataBound event. I can successfully manipulate the nested gridview (e.g., making some columns invisible) in the parent's PreRender event. And as I said, the display renders perfectly. The problem is that on post-back, I can't seem to actually find and act on the selected (checked) checkboxes...

Elsewhere, I have successfully implemented unbound checkboxes in a gridview and processed them in a button click event handler when no nesting is involved, so my current effort has been to adapt that approach for the nested gridview. Here's the button click handler that I have created and expect to be "seeing" the checkboxes, but it's not:

Protected Sub cmdEmailSelectedFiles_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles cmdEmailSelectedFiles.Click
' NOTE: parent gridview is named gvDocsAndRpts; child gridview is named gvDocFileSelect
Dim r1 As Integer
Dim r2 As Integer
Dim nestedGV As GridView
For r1 = 0 To gvDocsAndRpts.Rows.Count - 1 ' this works - it iterates the correct number of times
If (gvDocsAndRpts.Rows(r1).RowType = DataControlRowType.DataRow) Then
nestedGV = CType(gvDocsAndRpts.Rows(r1).FindControl("gvDocFil eSelect"), GridView)
For r2 = 0 To nestedGV.Rows.Count - 1 ' this doesn't work - nestedGV.Rows.Count is always zero
If CType(nestedGV.Rows(r2).FindControl("chkToEmail"), CheckBox).Checked Then
' code to handle a checked child row
End If
Next n
End If
Next r
' additional processing...
End Sub

Any help very much appreciated. Cheers,

Chris
Mar 6 '08 #1
2 2793
Quick amendment: I lightly edited the code I posted to focus it, but in the process I renamed the loop variables and forgot to rename them at the bottoms of the loops... rest assured the real code doesn't have that error, and that is not the explanation for my problems...
Mar 6 '08 #2
Problem resolved.

The problem was due to viewstate being disabled on the parent gridview. I had disabled viewstate long ago and was adding the nested gridview as a new feature - it didn't occur to me to even think about viewstate, in part because I could see some of the information about the nested gridview... of course, in hindsight I realize that the information I could see is all the static properties specified in the .aspx file.
Mar 7 '08 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: Hank | last post by:
I have two SQL Server 2000 machines (server_A and server_B). I've used sp_addlinkedserver to link them both, the link seems to behave fine. I can execute remote queries and do all types of neat...
8
by: L Major | last post by:
Hi Unfortunately, I am limited to using tables for part of my current project. I have a form that spans across a number of TR and TD in the shape of checkboxes. Doctype is XHTML 1.0...
3
by: Tcs | last post by:
My backend is DB2 on our AS/400. While I do HAVE DB2 PE for my PC, I haven't loaded it yet. I'm still using MS Access. And no, I don't believe this is an Access question. (But who knows? I...
46
by: TTroy | last post by:
Hi, I'm just wondering why people/books/experts say "the function returns a pointer to.." or "we have to send scanf a pointer to.." instead of "the function returns the address of.." or "we have...
2
by: Questman | last post by:
Good afternoon, Does anyone have any code that implements, or approaches implementing, a cross-browser DHTML/JS solution to provide an Excel-like Grid on a web page - I'm trying to convert an...
10
by: NH | last post by:
I have a girdview with paging enabled. How can I add a message in the footer to say "Viewing records 1-15 of 45" etc Thanks
1
by: scartin | last post by:
I'm fairly new to working with ASP web controls, and am running into what seems to be a ridiculous problem that I'm hoping will be a breeze for an experienced ASP developer. I have a GridView...
3
by: Darin | last post by:
I have a problem I just can't figure out. I have a form with a subform, and the recordsource of the subform has criteria based on some unbound fields in the parent form so that data in the parent...
0
by: =?ISO-8859-1?Q?Luis_M._Gonz=E1lez?= | last post by:
I apologize for this very basic question, but I can't understand how this works... I want to import a function from module B into my main script A, so this function can see and use the locals from...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.