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>&nbsp;</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=AtWorkWebPortal;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=AtWorkWebPortal;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.


        








 
Yahoo! Groups Links

<*> To visit your group on the web, go to:
    http://groups.yahoo.com/group/AspClassicAnyQuestionIsOk/

<*> To unsubscribe from this group, send an email to:
    [EMAIL PROTECTED]

<*> Your use of Yahoo! Groups is subject to:
    http://docs.yahoo.com/info/terms/
 



Reply via email to