Hi all,
I have a problem. I have a hash that has its keys bound to an asp:radiobuttonlist. When the form is submitted, the keys are checked. If a certain key matches the checked radio button, I spit out the value at that key. The value is an array full of links.
What I also have are asp:labels, each has an id that is the same as a key in the hash. I want to make that label appear. but i can't get it to work.
Here is a sample:
for each mykey2 in h.keys
if mykey2 = RBL.selecteditem.text then
match = h(mykey2) 'array set to another array
mykey2.visible = true
end if
next
match is an array. I later use it to bind to an asp:repeater for all the links.
The problem is mykey2.visible. Since mykey2 is a key, it really isn't an asp:label; so the .text property doesn't work. But how do I get it so that I can use the key to be the id of the asp:label? That is my problem.
Please, any help would be appreciated. keep in mind I am just using notepad. My vs.net copy should arrive shortly.
Mike
if you need to see all the code, look below:
I have a problem. I have a hash that has its keys bound to an asp:radiobuttonlist. When the form is submitted, the keys are checked. If a certain key matches the checked radio button, I spit out the value at that key. The value is an array full of links.
What I also have are asp:labels, each has an id that is the same as a key in the hash. I want to make that label appear. but i can't get it to work.
Here is a sample:
for each mykey2 in h.keys
if mykey2 = RBL.selecteditem.text then
match = h(mykey2) 'array set to another array
mykey2.visible = true
end if
next
match is an array. I later use it to bind to an asp:repeater for all the links.
The problem is mykey2.visible. Since mykey2 is a key, it really isn't an asp:label; so the .text property doesn't work. But how do I get it so that I can use the key to be the id of the asp:label? That is my problem.
Please, any help would be appreciated. keep in mind I am just using notepad. My vs.net copy should arrive shortly.
Mike
if you need to see all the code, look below:
Code:
<script runat="server" language="vb">
public a as New ArrayList()
public b as New ArrayList()
public c as New ArrayList()
public h as New HashTable()
Sub Page_Load(Source As Object, E As EventArgs)
a.add("[URL unfurl="true"]http://www.hotbot.com")[/URL]
a.add("[URL unfurl="true"]http://www.yahoo.com")[/URL]
a.add("[URL unfurl="true"]http://www.google.com")[/URL]
b.add("[URL unfurl="true"]http://www.cubs.com")[/URL]
b.add("[URL unfurl="true"]http://www.chicagobears.com")[/URL]
b.add("[URL unfurl="true"]http://www.blackhawks.com")[/URL]
c.add("[URL unfurl="true"]http://www.ford.com")[/URL]
c.add("[URL unfurl="true"]http://www.subaru.com")[/URL]
c.add("[URL unfurl="true"]http://www.dodge.com")[/URL]
h.add("AA", a)
h.add("BB", b)
h.add("CC", c)
if page.ispostback then
lBLRPT.visible = true
Formie.visible = false
'response.write("page posted back")
dim mykey2 as string
dim match as new ArrayList()
for each mykey2 in h.keys
if mykey2 = RBL.selecteditem.text then
match = h(mykey2)
if mykey2 = "CC" then
Summary.text = CC.text
elseif mykey2 = "BB" then
Summary.text = BB.text
elseif mykey2 = "AA" then
Summary.text = AA.text
end if
end if
next
RPT.DataSource = match
RPT.DataBind()
else
lBLRPT.visible = false
CC.visible = false
BB.visible = false
AA.visible = false
dim mykey as string
for each mykey in h.keys
response.write("<b>Key: " & mykey & "</b><br>")
dim elem as string
for each elem in h(mykey)
response.write("Value:_____" & elem & "<br>")
next
next
RBL.DataSource = h
RBL.DataTextField = "Key"
RBL.DataValueField = "Key"
RBL.DataBind()
end if
End Sub
</script>
<html>
<head>
<title></title>
</head>
<body bgcolor="#FFFFFF" topmargin="0" marginheight="0">
hi
<form method="post" runat="server" id="Formie">
<asp:radiobuttonlist id="RBL" runat="server">
</asp:radiobuttonlist><br />
<asp:button id="btn1" runat="server" />
</form>
<asp:label id="LBLRPT" runat="server">
<asp:repeater id="RPT" runat="server">
<itemtemplate>
<br />
<asp:hyperlink id="myLink" runat="server"
text='<%# Container.DataItem() %>' NavigateUrl='<%# Container.DataItem() %>' /></b>
</itemtemplate>
</asp:repeater>
</asp:label>
<asp:label id="Summary" runat="server" text="hi"/>
<asp:label id="CC" runat="server" text="I am CC label"/>
<asp:label id="BB" runat="server" text="I am BB label"/>
<asp:label id="AA" runat="server" text="I am AA label"/>
</body>
</html>