473,803 Members | 3,616 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Adding Controls that are not a checkboxlist of radiobuttonlist

Hello,

I know I can use a Checkboxlist or a RadioButtonList to easily create a list
based on the data passed to it.

But using what if I wanted to use the same data and based on the data,
return either a textbox or checkbox (or even a user control). What is the
best way to do that?

Thanks for the help.

-Gummy
Nov 19 '05 #1
3 1462
Gummy,

In the situation you describe I would use a repeater with a column template.
Then I'd use the repeater's ItemDataBound event to examine the data and set
controls in the current row visible/hidden as necessary.

--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

www.aboutfortunate.com

"Out of chaos comes order."
Nietzsche
"Gummy" <gu***@nowhere. com> wrote in message
news:11******** *****@corp.supe rnews.com...
Hello,

I know I can use a Checkboxlist or a RadioButtonList to easily create a
list
based on the data passed to it.

But using what if I wanted to use the same data and based on the data,
return either a textbox or checkbox (or even a user control). What is the
best way to do that?

Thanks for the help.

-Gummy

Nov 19 '05 #2
Thank you for the information.

Now, how do I reference each row? Here is the code I am using:

Private Sub dlYesNo_ItemDat aBound(ByVal sender As Object, ByVal e As
System.Web.UI.W ebControls.Data ListItemEventAr gs) Handles
dlYesNo.ItemDat aBound
Dim ds As DataSet
Dim dr As DataRow
Dim strSQL As String
Dim rd As New ClassSurvey.Dat aTransfer

strSQL = String.Format(" Select QuesID, Question, QuestionType from
tblQuestions;")

'Get a DataSet from the SQL and the Connection String
ds = rd.GetDataSet(s trSQL, rd.CONN_STR)

For Each dr In ds.Tables(0).Ro ws
Debug.WriteLine (dr.Item("QuesI D"))

If CStr(dr.Item("Q uesID")) = "1" Or CStr(dr.Item("Q uesID")) = "4" Then
e.Item.FindCont rol("rblQues3") .Visible = False
Else
e.Item.FindCont rol("rblQues3") .Visible = True
End If

Next

I know this isn't pretty code, but it make that RadioListBox invisible for
all the rows.

What is the best way to approach this?

Thanks again for all your help.

"S. Justin Gengo" <justin@[no_spam_please]aboutfortunate. com> wrote in
message news:%2******** ********@tk2msf tngp13.phx.gbl. ..
Gummy,

In the situation you describe I would use a repeater with a column template. Then I'd use the repeater's ItemDataBound event to examine the data and set controls in the current row visible/hidden as necessary.

--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

www.aboutfortunate.com

"Out of chaos comes order."
Nietzsche
"Gummy" <gu***@nowhere. com> wrote in message
news:11******** *****@corp.supe rnews.com...
Hello,

I know I can use a Checkboxlist or a RadioButtonList to easily create a
list
based on the data passed to it.

But using what if I wanted to use the same data and based on the data,
return either a textbox or checkbox (or even a user control). What is the best way to do that?

Thanks for the help.

-Gummy


Nov 19 '05 #3
The repeater has an overridable ItemDataboundEv ent that you may use to break
into each row as the data is being bound to it. You can access each row as
an item and refer to the controls in the template.

Inside it would look something like this:

e.Item(0).Contr ols(0).Visible = false;

Where the first zero is first column in the zero based column and the second
zero is the first control in the zero based index of controls in that
column.

--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

www.aboutfortunate.com

"Out of chaos comes order."
Nietzsche
"Gummy" <gu***@nowhere. com> wrote in message
news:11******** *****@corp.supe rnews.com...
Thank you for the information.

Now, how do I reference each row? Here is the code I am using:

Private Sub dlYesNo_ItemDat aBound(ByVal sender As Object, ByVal e As
System.Web.UI.W ebControls.Data ListItemEventAr gs) Handles
dlYesNo.ItemDat aBound
Dim ds As DataSet
Dim dr As DataRow
Dim strSQL As String
Dim rd As New ClassSurvey.Dat aTransfer

strSQL = String.Format(" Select QuesID, Question, QuestionType from
tblQuestions;")

'Get a DataSet from the SQL and the Connection String
ds = rd.GetDataSet(s trSQL, rd.CONN_STR)

For Each dr In ds.Tables(0).Ro ws
Debug.WriteLine (dr.Item("QuesI D"))

If CStr(dr.Item("Q uesID")) = "1" Or CStr(dr.Item("Q uesID")) = "4" Then
e.Item.FindCont rol("rblQues3") .Visible = False
Else
e.Item.FindCont rol("rblQues3") .Visible = True
End If

Next

I know this isn't pretty code, but it make that RadioListBox invisible for
all the rows.

What is the best way to approach this?

Thanks again for all your help.

"S. Justin Gengo" <justin@[no_spam_please]aboutfortunate. com> wrote in
message news:%2******** ********@tk2msf tngp13.phx.gbl. ..
Gummy,

In the situation you describe I would use a repeater with a column

template.
Then I'd use the repeater's ItemDataBound event to examine the data and

set
controls in the current row visible/hidden as necessary.

--
Sincerely,

S. Justin Gengo, MCP
Web Developer / Programmer

www.aboutfortunate.com

"Out of chaos comes order."
Nietzsche
"Gummy" <gu***@nowhere. com> wrote in message
news:11******** *****@corp.supe rnews.com...
> Hello,
>
> I know I can use a Checkboxlist or a RadioButtonList to easily create a
> list
> based on the data passed to it.
>
> But using what if I wanted to use the same data and based on the data,
> return either a textbox or checkbox (or even a user control). What is the > best way to do that?
>
> Thanks for the help.
>
> -Gummy
>
>



Nov 19 '05 #4

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

Similar topics

1
5384
by: Tom | last post by:
Hi, I have a webform which has DropDownList, RadioButtonList and CheckBoxList. All values are in webform, but not select from DB table as they do not need to be used as search requirements. For DropDownList and RadioButtonList, there is only one item is selected and store in DB table.
4
1603
by: Sandeep | last post by:
Hi I am doing one thing in my website ,actually i want to add controls dynamically to a web form and want to access the elements but when i postback the form,and access that control, it gives error Object reference not set to an instance of an object. ************************************************************************ ************************************************************************** Public Class index2 Inherits...
0
1013
by: Nobody | last post by:
CheckBoxList and RadioButtonList have the same inheritence tree: -INamingContainer -IPostBackDataHandler -IRepeatInfoUser --ListControl ----WebControl ------Control --------IComponent ----------IDisposable
0
2532
by: Boris | last post by:
When I dynamically create CheckButtonList, I add ListItem(s) to my CheckButtonList object chkList chkList.Items.Add(new ListItem("My Text", "My Value")); The resulting HTML doesn't contain value="My Value". Therefore, I can't access "My Value" with Request.Form on post back. I do get the desired outcome with my RadioButtonList object radioList when I do
4
2095
by: Bass Pro | last post by:
Hi, I am creating textbox, radiobuttonlist and checkboxlist dynamically depending on data from a table. It is a questionnaire. I add the control on a Panel control during the 1st load_page event. Each question is displayed and answered, then result written to a SQL table. Then the next question is read from a table and displayed using the load_page event again. The questions display and function perfectly. The user anwers the question...
4
6545
by: MattB | last post by:
I have a CheckBoxList that under some circumstances I want to only allow one selection, so that if you select a different item, whatever was selected before becomes un-selected. Any ideas on how to do this? Ideas, and even better, examples would be appreciated! Matt
14
7975
by: Satheesh Babu B | last post by:
hai.. am having a checkboxlist..now how do i get the value of the checkbox that is checked in checkboxlist using javascript? Thanks in advance.... Regards,
4
2430
by: Marty | last post by:
I am using: VS2005 Pro WinXP Pro SP2 IIS 5.1 ..NET Framework 2.0.50727 I create a website using File>New>Web Site>ASP.NET. I put a ListBox, DropDownList, CheckBoxList and RadioButtonList on the default page. Compile the page and surf to it using IE or Firefox (I get the same
0
1306
by: Nathan Sokalski | last post by:
In the RadioButton and CheckBox controls, there is no Value attribute. The html <inputtag has a value attribute, which is used by both type="radio" and type="checkbox". The RadioButtonList and CheckBoxList controls have SelectedValue properties (I realize that the RadioButtonList uses the <selectand <optiontags instead of the <inputtag, but needing a value server-side exists either way). I am attempting to write a control with...
0
9703
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
10548
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
10295
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,...
1
7604
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
6842
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5500
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
5629
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3798
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2970
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.