[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

microsoft.public.dotnet.framework.aspnet.webcontrols

RE: Problem with embedded checkbox in datagrid

v-jetan

2/26/2004 3:19:00 AM


Hi Pat Laf,

Again, I will help you :-). Sorry for letting you wait for so long time, I
am too busy yesterday, anyway, I will follow up you here.

Oh, from the description in this post, I think your problem is that: you
collect the checkbox column's checked state in the Item_Command event of
MASTER datagrid.(Sorry for misunderstand you in last post). When the user
click the "Hide Details" button, you want to ONLY collect the checked state
of the DETAILS datagrid in current MASTER datagrid row(Not the whole 34
DETAILS datagrid).

I think the problem is in your code.

Dim tc As TableCell = dgi.Cells(7)
For Each dgi In dgDefects.Items
Dim c As Control
Dim dgi2 As DataGridItem
For Each c In tc.Controls
If TypeOf (c) Is System.Web.UI.WebControls.DataGrid Then
m_dgDetails = CType(e.Item.FindControl("m_dgDetails"),
DataGrid)
For Each dgi2 In m_dgDetails.Items
If CType(dgi2.FindControl("chkboxSelDetails"),
CheckBox).Checked = True Then
Me.Response.Write("The " &
dgi2.ItemIndex.ToString() & "th row is selected in Details datagrid<br>")
End If
Next dgi2
End If
Next c
Next dgi

In the code snippet , you first loop through all the Items(Rows) of the
MASTER datagrid(This loop will occur 34 times), then in the loop, you
collect the DETAILS datagrid in dgi.Cells(7)(This is the DETAILS datagrid
in current row). So althrough you have succeeded collect the checked state
of current row, but it loops 34 times(Because you loop the whole 34 rows in
MASTER datagrid). That why you get checked = true 34 times.

You can just remove the loop of the dgDefects(MASTER datagrid) code, like
this:

Dim tc As TableCell = dgi.Cells(7)
Dim c As Control
Dim dgi2 As DataGridItem
For Each c In tc.Controls
If TypeOf (c) Is System.Web.UI.WebControls.DataGrid Then
m_dgDetails = CType(e.Item.FindControl("m_dgDetails"),
DataGrid)
For Each dgi2 In m_dgDetails.Items
If CType(dgi2.FindControl("chkboxSelDetails"),
CheckBox).Checked = True Then
Me.Response.Write("The " &
dgi2.ItemIndex.ToString() & "th row is selected in Details datagrid<br>")
End If
Next dgi2
End If
Next c

Then, I think Response.Write should only output once.

For your another concern in last post, you can not view my post in the link
I provide you. But I have tried that link, I can view it in my side.
Anyway, you can just search keyword:
"Jeffrey Tan" INamingContainer csharp
in http://groups.g..., then you can find that post.

=================================================
Thank you for your patience and cooperation. If you have any questions or
concerns, please feel free to post it in the group. I am standing by to be
of assistance.
Have a nice day!!

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.