CodeKicks.com
Focus on Microsoft Technologies - Tutorials, Articles, Code Samples.

Saturday, September 02, 2006

Dynamically add link buttons

// Author: Krishna Chovdry//Description: Dynamically add link buttonsPrivate Sub CreateLinks()        Dim br As New Label        Dim prevmonth, curmonth As Integer        Dim lbl As New Label        br.Text = "<br>"        con = obj.getConnection        cmd.Connection = con        cmd.CommandText = "Select * from postings order by posteddate DESC"        reader = cmd.ExecuteReader        While (reader.Read)            posteddate = reader(1)            curmonth = posteddate.Month            If (curmonth = prevmonth) Then                prevmonth = curmonth            Else                lbl.Text = posteddate.ToShortDateString                ph.Controls.Add(lbl)                ph.Controls.Add(New LiteralControl("<br>"))            End If            requireddate = reader(2)            professionalinfo = reader(4)            gender = reader(5)            age = reader(6)            purpose = reader(7)            seeking = reader(8)            seekerage = reader(9)            postid = reader(14)            lnk(i) = New LinkButton            lnk(i).ID = postid            lnk(i).Text = gender + " " + age + "  is looking for" + " " + seekerage + " " + seeking + " " + "for" + " " + purpose            'lnk(i).Attributes.Add("onClick", "lnkbtnClick()")            AddHandler lnk(i).Click, AddressOf lnkbtnClick            ph.Controls.Add(lnk(i))            ph.Controls.Add(New LiteralControl("<br>"))            i += 1        End While        con.Close()    End Sub

Post a Comment