473,326 Members | 2,815 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,326 software developers and data experts.

handling an event for a control embedded in a datalist

I have a datagrid inside a datalist. The datalist shows parent info and the datagrid shows the child info for that parent. There is a checkbox on each row of the child datagrid. Also inside the datalist is a radiobuttonlist. When this radiobuttonlist is checked, I would like it to iterate thru each row on the child grid and either select or deselct the checkboxes (which are on each row of the child datagrid). In addition, the user can also check each of these checkboxes individually as well. btw, I made the columns that I need to access inside the datagrid template columns. For the rows that are checked, I want to save them to a dataset.

I created code below to do the above task:
Private Sub DataList1_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles DataList1.SelectedIndexChanged

'Capture the postback event from the radiobuttonlist

Dim rblConditions As RadioButtonList = DirectCast(FindControl("RadioButtonList1"), RadioButtonList)

Dim dg2 As DataGrid = DirectCast(FindControl("DataGrid2"), DataGrid)

Dim chkCondition As CheckBox = DirectCast(FindControl("Condition"), CheckBox)

Dim lblLockNumber As Label = DirectCast(FindControl("LockNumber"), Label)

Dim lblConditionDetailID As Label = DirectCast(FindControl("ConditionDetailID"), Label)

Dim lblLoanID As Label = DirectCast(FindControl("LoanID"), Label)

Dim i As Int16

If rblConditions.SelectedIndex = YesNoIndex.YES Then

'check all the boxes in the child datagrid

For i = 0 To dg2.Items.Count - 1

chkCondition.Checked = True

Next

Else

'uncheck all the boxes in the child datagrid

For i = 0 To dg2.Items.Count - 1

chkCondition.Checked = False

Next

End If

For i = 0 To dg2.Items.Count - 1

If chkCondition.Checked = True Then

Dim drSave As dsSaveCondition.dsSaveConditionRow = DsSaveCondition1.dsSaveCondition.NewdsSaveConditio nRow

drSave.Lock_Number = lblLockNumber.Text

drSave.ConditionDetailID = lblConditionDetailID.Text

drSave.LoanID = lblLoanID.Text

DsSaveCondition1.dsSaveCondition.Rows.Add(drSave)

End If

Next

If ViewState.Item("DsSaveCondition1") Is Nothing Then

DsSaveCondition1.AcceptChanges()

Else

DsSaveCondition1 = DirectCast(ViewState.Item("DsSaveCondition1"), DataSet)

End If

ViewState.Item("DsSaveCondition1") = DsSaveCondition1

End Sub


Since I won't be able to test this out until Monday, I'm wondering if the above code is "on target". I'm unsure of how to handle the postback event from the radiobuttonlist (autopostback is set to TRUE) which is inside the datalist as well as cycling thru the datagrid rows to check or uncheck the boxes.

Can someone please tell me if I need to do anything else?

Your help is greatly appreciated...

************************************************** ********************
Sent via Fuzzy Software @ http://www.fuzzysoftware.com/
Comprehensive, categorised, searchable collection of links to ASP & ASP.NET resources...
Nov 18 '05 #1
1 4675
I know the datalist can respond to events from child
button controls via the ITEMCommand event, etc of the
Datalists ItemCommand event. But, can the datalist handle
events such as the one I have outlined in the previous
message, particularly selecting a child radiobutton
inside the datalist, posting the page back and responding
to which radiobutton was checked (inside the datalist)
and then programmatically selecting check boxes on a
child datagrid within the datalist.

I presently have the code to do this inside
the "DataList1_SelectedIndexChanged" event (as described
in my previous msg). If this is not the case, I would
then try to place the code inside an event that I would
set up in the HTML as follows for the radiobuttonlist:
OnSelectedIndexChanged="rblRadioButtonList1_Select edIndexC
hanged"

I then would have an event in code-behind which will
handle this:
Protected WithEvents RadioButtonList1 As RadioButtonList
..
..
..
Private Sub rblRadioButtonList1_SelectedIndexChanged
(ByVal sender As Object, ByVal e As System.EventArgs)
Handles RadioButtonList1.SelectedIndexChanged

Can someone please tell me if I'm target with this?
-----Original Message-----
I have a datagrid inside a datalist. The datalist shows parent info and the datagrid shows the child info for
that parent. There is a checkbox on each row of the child
datagrid. Also inside the datalist is a radiobuttonlist.
When this radiobuttonlist is checked, I would like it to
iterate thru each row on the child grid and either select
or deselct the checkboxes (which are on each row of the
child datagrid). In addition, the user can also check
each of these checkboxes individually as well. btw, I
made the columns that I need to access inside the
datagrid template columns. For the rows that are checked,
I want to save them to a dataset.
I created code below to do the above task:
Private Sub DataList1_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles
DataList1.SelectedIndexChanged
'Capture the postback event from the radiobuttonlist
Dim rblConditions As RadioButtonList = DirectCast (FindControl("RadioButtonList1"), RadioButtonList)
Dim dg2 As DataGrid = DirectCast(FindControl ("DataGrid2"), DataGrid)
Dim chkCondition As CheckBox = DirectCast (FindControl("Condition"), CheckBox)
Dim lblLockNumber As Label = DirectCast (FindControl("LockNumber"), Label)
Dim lblConditionDetailID As Label = DirectCast (FindControl("ConditionDetailID"), Label)
Dim lblLoanID As Label = DirectCast(FindControl ("LoanID"), Label)
Dim i As Int16

If rblConditions.SelectedIndex = YesNoIndex.YES Then
'check all the boxes in the child datagrid

For i = 0 To dg2.Items.Count - 1

chkCondition.Checked = True

Next

Else

'uncheck all the boxes in the child datagrid

For i = 0 To dg2.Items.Count - 1

chkCondition.Checked = False

Next

End If

For i = 0 To dg2.Items.Count - 1

If chkCondition.Checked = True Then

Dim drSave As dsSaveCondition.dsSaveConditionRow =
DsSaveCondition1.dsSaveCondition.NewdsSaveConditio nRow
drSave.Lock_Number = lblLockNumber.Text

drSave.ConditionDetailID = lblConditionDetailID.Text
drSave.LoanID = lblLoanID.Text

DsSaveCondition1.dsSaveCondition.Rows.Add (drSave)
End If

Next

If ViewState.Item("DsSaveCondition1") Is Nothing Then
DsSaveCondition1.AcceptChanges()

Else

DsSaveCondition1 = DirectCast(ViewState.Item ("DsSaveCondition1"), DataSet)
End If

ViewState.Item("DsSaveCondition1") = DsSaveCondition1
End Sub


Since I won't be able to test this out until Monday, I'm wondering if the above code is "on target". I'm unsure of
how to handle the postback event from the radiobuttonlist
(autopostback is set to TRUE) which is inside the
datalist as well as cycling thru the datagrid rows to
check or uncheck the boxes.
Can someone please tell me if I need to do anything else?
Your help is greatly appreciated...

************************************************* ******** *************Sent via Fuzzy Software @ http://www.fuzzysoftware.com/
Comprehensive, categorised, searchable collection of links to ASP & ASP.NET resources....

Nov 18 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Hardy Wang | last post by:
Hi all; I have a DataList with ItemCreated event like below: private void myList_ItemCreated(object sender , DataListItemEventArgs e) { DataRowView myRowView; DataRow myRow; if (e.Item.DataItem...
1
by: Doug | last post by:
The html below shows DataList "DiscountList" nested within DataList "EventItemList". DiscountList contains a Label control. I'm trying to find the label, using FindControl, during...
0
by: Gaurav Gargate | last post by:
Hi Group, I am creating a ASP.NET (C#) project. I am creating a datalist with some dynamically generated text boxes in the edit template. I have the datalist control on the form. The text box...
0
by: manu_srinivasa | last post by:
:( Here is my design, we have user control placed in a aspx page. within user control, i am having datalist, within datalist i am placing radio button. On click of radio button, i need to...
0
by: John Boldt | last post by:
I have a datalist control embedded within a repeater control. For some reason, the ItemCreated event fires twice for each data row. If I take the datalist out of the repeater control, it works...
0
by: Maran | last post by:
We have come across a situation that I thinks not many have. Grateful for all responses. Regards Maran ************* * Scenario A DataList binds to a DataRow, with "RegionName" och...
0
by: Bieniu | last post by:
I have DataList control on my own contro land it is bind to SqlDataSource control. My problem is that DataList is getting needed data twice what is for me very strange. I have some code in...
0
by: CMELLO | last post by:
I have am dynamically loading a web user control based on the click of a tab strip I load the default control for the first tab in the page load event after checking page is not postback. After...
0
by: =?Utf-8?B?Y2luZHk=?= | last post by:
I have am dynamically loading a web user control based on the click of a tab strip I load the default control for the first tab in the page load event after checking page is not postback. After...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.