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

radiobutton list and url link

Hi,
Good day.i need some help from you guys.

I'm using vb.net and sql database to build my file.
The purpose of this file is to view news based on deparment.

Im using listbox and radiobutton list in this file.

listbox- to get department names in sql table
radiobutton - to get the headline news for the department name choosen

above.

However, i managed to list all the headline news based on the
department name using listbox and radiobutton.

THE PROBLEM now is how to assign an url link to an item in this
radiobutton list so it will link to the related news.For your
information url addresses are stored in a tabel.
Here are the html declaration:

<form id="Form1" method="post" runat="server">
<P><asp:listbox id="lblCategory"
OnSelectedIndexChanged="DisplayCategory" AutoPostBack="True"
Font-Size="8pt"
Font-Name="arial"
Runat="server"></asp:listbox></P>
<P> </P>
<asp:radiobuttonlist id="rblSubject" Font-Size="8pt"
Font-Name="arial" Runat="server"
RepeatColumns="1"></asp:radiobuttonlist>
</form>

Here are the vb code :

Inherits System.Web.UI.Page
Protected WithEvents lblCategory As ListBox
Protected WithEvents rblSubject As RadioButtonList

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
'Put user code to initialize the page here

If Not Page.IsPostBack Then
Dim cn As New
SqlConnection("server=(local);database=AtWorkWebPo rtal;uid=me;pwd=me")
Dim sql As String = "select DepartmentID, DepartmentName
from Department "
Dim cm As New SqlCommand(sql, cn)
Dim dr As SqlDataReader

cn.Open()
dr = cm.ExecuteReader
lblCategory.DataSource = dr
lblCategory.DataTextField = "DepartmentName"
lblCategory.DataValueField = "DepartmentID"
lblCategory.DataBind()
lblCategory.Rows = lblCategory.Items.Count

cn.Close()
dr = Nothing
cm = Nothing
cn = Nothing
End If

Public Sub DisplayCategory(ByVal o As Object, ByVal e As EventArgs)

If lblCategory.SelectedIndex <> -1 Then
Dim cn As New
SqlConnection("server=(local);database=AtWorkWebPo rtal;uid=me;pwd=me")
Dim sql As String = "select DepartmentItemID, ItemDescr
FROM DepartmentItem WHERE DepartmentID = @DepartmentID "
Dim cm As New SqlCommand(sql, cn)
Dim pm As SqlParameter
Dim dr As SqlDataReader
Dim li As ListItem
pm = cm.Parameters.Add(New SqlParameter("@DepartmentID",
SqlDbType.Int))
pm.Value = lblCategory.SelectedItem.Value

cn.Open()
dr = cm.ExecuteReader
rblSubject.DataSource = dr
rblSubject.DataTextField = "ItemDescr"
rblSubject.DataValueField = "DepartmentItemID"
rblSubject.DataBind()

dr.NextResult()
If dr.Read Then
For Each li In rblSubject.Items
If li.Value = dr("DepartmentItemID") Then
li.Selected = True
Exit For
End If
Next
End If

cn.Close()
dr = Nothing
cm = Nothing
cn = Nothing

End If
Is there any declaration and alteration i need to make?

thank you for your attention.hope to hear from you guys soon.

*-----------------------*
Posted at:
www.GroupSrv.com
*-----------------------*
Nov 21 '05 #1
0 1280

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

Similar topics

8
by: VK | last post by:
Hi! What I'm missing in following code? Cannot get the values of radiobuttons. Starting only one class (GetVariant), it works. When I put two classes together, it doesn't. Regards, VK from...
11
by: William Gill | last post by:
I am placing radiobuttons in a 4 X 4 matrix (using loops) and keep references to them in a 2 dimensional list ( rBtns ). It works fine, and I can even make it so only one button per column can be...
3
by: sofie | last post by:
Hello all, I use the following javascript function in a html document to set the level of one of eight available radiobuttons. The line that's commented out works fine under IE, but I need to...
1
by: Sean | last post by:
hi, I have a radiobutton list say, Florida | New York | New Jersey | Texas the radiobutton list has autopostback set to true, as i fire up some code after one of the radiobuttons are...
1
by: Gerald | last post by:
Hi, I'm struggling to create a radiobutton list in asp.net c#. I dont want any formatting like the radiobuttonlist do. How can I create checkbox that uses runat server and dont have any...
3
by: visual2005beta_developer | last post by:
I have the following problem (especially with the groupname-attribut of the RadioButton-Control) when developing in Visual Studio 2005 Beta. I load an ascx-control in an aspx-page. This...
4
by: Ankit Aneja | last post by:
code of my aspx page <asp:RadioButtonList id="RadioButtonList1" runat="server"></asp:RadioButtonList> now i want to bind data from database Dim rsComm As SqlCommand Dim rsReader As...
1
by: Vikas Kumar | last post by:
Hi Guys, Can I hav image with radiobuttonlist control instead of text....? Pls help me in this concern...
1
by: Christiano Donke | last post by:
Hy there, pla.. i have 2 nested repeaters. In the child i have 3 radiobuttons. Already made my homework and figured out how to allow only one radio to be checked.... but now, i can't find...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
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...
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
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...

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.