473,413 Members | 1,829 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,413 software developers and data experts.

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 1445
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.supernews.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_ItemDataBound(ByVal sender As Object, ByVal e As
System.Web.UI.WebControls.DataListItemEventArgs) Handles
dlYesNo.ItemDataBound
Dim ds As DataSet
Dim dr As DataRow
Dim strSQL As String
Dim rd As New ClassSurvey.DataTransfer

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

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

For Each dr In ds.Tables(0).Rows
Debug.WriteLine(dr.Item("QuesID"))

If CStr(dr.Item("QuesID")) = "1" Or CStr(dr.Item("QuesID")) = "4" Then
e.Item.FindControl("rblQues3").Visible = False
Else
e.Item.FindControl("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****************@tk2msftngp13.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.supernews.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 ItemDataboundEvent 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).Controls(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.supernews.com...
Thank you for the information.

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

Private Sub dlYesNo_ItemDataBound(ByVal sender As Object, ByVal e As
System.Web.UI.WebControls.DataListItemEventArgs) Handles
dlYesNo.ItemDataBound
Dim ds As DataSet
Dim dr As DataRow
Dim strSQL As String
Dim rd As New ClassSurvey.DataTransfer

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

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

For Each dr In ds.Tables(0).Rows
Debug.WriteLine(dr.Item("QuesID"))

If CStr(dr.Item("QuesID")) = "1" Or CStr(dr.Item("QuesID")) = "4" Then
e.Item.FindControl("rblQues3").Visible = False
Else
e.Item.FindControl("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****************@tk2msftngp13.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.supernews.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
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. ...
4
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...
0
by: Nobody | last post by:
CheckBoxList and RadioButtonList have the same inheritence tree: -INamingContainer -IPostBackDataHandler -IRepeatInfoUser --ListControl ----WebControl ------Control --------IComponent...
0
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...
4
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....
4
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...
14
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
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...
0
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...
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
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...
0
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,...
0
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...
0
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...

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.