473,608 Members | 2,457 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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_Selec tedIndexChanged (ByVal sender As Object, ByVal e As System.EventArg s) Handles DataList1.Selec tedIndexChanged

'Capture the postback event from the radiobuttonlist

Dim rblConditions As RadioButtonList = DirectCast(Find Control("RadioB uttonList1"), RadioButtonList )

Dim dg2 As DataGrid = DirectCast(Find Control("DataGr id2"), DataGrid)

Dim chkCondition As CheckBox = DirectCast(Find Control("Condit ion"), CheckBox)

Dim lblLockNumber As Label = DirectCast(Find Control("LockNu mber"), Label)

Dim lblConditionDet ailID As Label = DirectCast(Find Control("Condit ionDetailID"), Label)

Dim lblLoanID As Label = DirectCast(Find Control("LoanID "), Label)

Dim i As Int16

If rblConditions.S electedIndex = YesNoIndex.YES Then

'check all the boxes in the child datagrid

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

chkCondition.Ch ecked = True

Next

Else

'uncheck all the boxes in the child datagrid

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

chkCondition.Ch ecked = False

Next

End If

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

If chkCondition.Ch ecked = True Then

Dim drSave As dsSaveCondition .dsSaveConditio nRow = DsSaveCondition 1.dsSaveConditi on.NewdsSaveCon ditionRow

drSave.Lock_Num ber = lblLockNumber.T ext

drSave.Conditio nDetailID = lblConditionDet ailID.Text

drSave.LoanID = lblLoanID.Text

DsSaveCondition 1.dsSaveConditi on.Rows.Add(drS ave)

End If

Next

If ViewState.Item( "DsSaveConditio n1") Is Nothing Then

DsSaveCondition 1.AcceptChanges ()

Else

DsSaveCondition 1 = DirectCast(View State.Item("DsS aveCondition1") , DataSet)

End If

ViewState.Item( "DsSaveConditio n1") = DsSaveCondition 1

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 4697
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 programmaticall y selecting check boxes on a
child datagrid within the datalist.

I presently have the code to do this inside
the "DataList1_Sele ctedIndexChange d" 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 :
OnSelectedIndex Changed="rblRad ioButtonList1_S electedIndexC
hanged"

I then would have an event in code-behind which will
handle this:
Protected WithEvents RadioButtonList 1 As RadioButtonList
..
..
..
Private Sub rblRadioButtonL ist1_SelectedIn dexChanged
(ByVal sender As Object, ByVal e As System.EventArg s)
Handles RadioButtonList 1.SelectedIndex Changed

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_Selec tedIndexChanged (ByVal sender As Object, ByVal e As System.EventArg s) Handles
DataList1.Selec tedIndexChanged
'Capture the postback event from the radiobuttonlist
Dim rblConditions As RadioButtonList = DirectCast (FindControl("R adioButtonList1 "), RadioButtonList )
Dim dg2 As DataGrid = DirectCast(Find Control ("DataGrid2" ), DataGrid)
Dim chkCondition As CheckBox = DirectCast (FindControl("C ondition"), CheckBox)
Dim lblLockNumber As Label = DirectCast (FindControl("L ockNumber"), Label)
Dim lblConditionDet ailID As Label = DirectCast (FindControl("C onditionDetailI D"), Label)
Dim lblLoanID As Label = DirectCast(Find Control ("LoanID"), Label)
Dim i As Int16

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

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

chkCondition.Ch ecked = True

Next

Else

'uncheck all the boxes in the child datagrid

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

chkCondition.Ch ecked = False

Next

End If

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

If chkCondition.Ch ecked = True Then

Dim drSave As dsSaveCondition .dsSaveConditio nRow =
DsSaveCondition 1.dsSaveConditi on.NewdsSaveCon ditionRow
drSave.Lock_Num ber = lblLockNumber.T ext

drSave.Conditio nDetailID = lblConditionDet ailID.Text
drSave.LoanID = lblLoanID.Text

DsSaveCondition 1.dsSaveConditi on.Rows.Add (drSave)
End If

Next

If ViewState.Item( "DsSaveConditio n1") Is Nothing Then
DsSaveCondition 1.AcceptChanges ()

Else

DsSaveCondition 1 = DirectCast(View State.Item ("DsSaveConditi on1"), DataSet)
End If

ViewState.Item( "DsSaveConditio n1") = DsSaveCondition 1
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/
Comprehensiv e, 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
4724
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 != null) { Trace.Write(e.Item.ItemType.ToString(), "---with data"); } else { Trace.Write(e.Item.ItemType.ToString(), "---without data"); }
1
3163
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 EventList_ItemCreated (below the html), but it's always <undefined value> (null). Everything else works fine. Eventually I need to set the value of the label depending up the Count of the DataView "dvDiscount". For now I'll settle for just finding the damn...
0
1216
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 is written on the form at run time. Using Response.Write() on the EditTemplate I write the HTML code required for the text box along with the data and the ID for the text box.
0
1639
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 know the seleceted row of the datalist. radiobutton checkchanged event is not firing.
0
1408
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 fine. What's going on? --- Posted using Wimdows.net Newsgroups - http://www.wimdows.net/newsgroups/
0
1126
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 "RegionShortName",
0
1082
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 OnSelected event of SqlDataSource, and i was suprised when it was fired twice for every page loading. His is code of datalist: <tr> <td style="width: 5%;"> </td> <td colspan="3">
0
2933
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 that the controls are loaded/unloaded based on the SelectionChanged event for the tab strip and again in Page load because with a dynamic load viewstate has to be reloaded. I have a datalist in the user control and I am trying to create the...
0
1907
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 that the controls are loaded/unloaded based on the SelectionChanged event for the tab strip and again in Page load because with a dynamic load viewstate has to be reloaded. I have a datalist in the user control and I am trying to create the...
0
8059
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8000
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8495
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8145
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8330
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6011
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
3960
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4023
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1328
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.