B
Bob
Hi,
i created linkbuttons dynamically with titles of newspapers as text.
When clicking on a linkbutton, i want to fetch the corresponding title and
text and to show them on this page in the two labels created in aspx file.
<form id="form1" runat="server">
<asp:Label ID="labeltitle" runat="server"></asp:Label><br />
<asp:Label ID="labeltxt" runat="server"></asp:Label><br />
</form>
My problem is that i need to know which linkbutton has been clicked in the
submit_click procedure.
Here below my code.
Thanks
Bob
' tot = numbers of titles
redim nr(tot), tit(tot), txt(tot)
sql = "select id,title,text from newspapers "
comd = New SqlCommand(sql, mConnection)
dtreader = comd.ExecuteReader()
If dtreader.HasRows Then
While dtreader.Read()
i = i + 1
nr(i) = dtreader.GetValue(0)
tit(i) = dtreader.GetString(1)
txt(i) = dtreader.GetString(2)
lb(i) = New LinkButton
lb(i).Text = dtreader.GetString(1)
form1.Controls.Add(lb(i))
lit = New LiteralControl("<br>")
form1.Controls.Add(lit)
AddHandler lb(i).Click, AddressOf submit_Click
End While
End If
dtreader.Close()
Protected Sub submit_Click(ByVal sender As Object, ByVal e As
System.EventArgs)
labeltitle.text=???
labeltxt.text=???
End Sub
i created linkbuttons dynamically with titles of newspapers as text.
When clicking on a linkbutton, i want to fetch the corresponding title and
text and to show them on this page in the two labels created in aspx file.
<form id="form1" runat="server">
<asp:Label ID="labeltitle" runat="server"></asp:Label><br />
<asp:Label ID="labeltxt" runat="server"></asp:Label><br />
</form>
My problem is that i need to know which linkbutton has been clicked in the
submit_click procedure.
Here below my code.
Thanks
Bob
' tot = numbers of titles
redim nr(tot), tit(tot), txt(tot)
sql = "select id,title,text from newspapers "
comd = New SqlCommand(sql, mConnection)
dtreader = comd.ExecuteReader()
If dtreader.HasRows Then
While dtreader.Read()
i = i + 1
nr(i) = dtreader.GetValue(0)
tit(i) = dtreader.GetString(1)
txt(i) = dtreader.GetString(2)
lb(i) = New LinkButton
lb(i).Text = dtreader.GetString(1)
form1.Controls.Add(lb(i))
lit = New LiteralControl("<br>")
form1.Controls.Add(lit)
AddHandler lb(i).Click, AddressOf submit_Click
End While
End If
dtreader.Close()
Protected Sub submit_Click(ByVal sender As Object, ByVal e As
System.EventArgs)
labeltitle.text=???
labeltxt.text=???
End Sub