1

我的页面中有此代码,我希望每个 NavigateUrl 都显示另一个页面,例如: simple.aspx?id=1、、simple.aspx?id=2...

其中 id =c

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)
 Dim c As Integer = 0
  While c < 5
   Dim Label1 As New Label()
   Dim ltr As New Literal()     
   Dim link As New HyperLink()
   link.NavigateUrl = "simple.aspx"
   link.BackColor = Drawing.Color.Aqua            
   Label1.Text = c.ToString()
   ltr.Text = "<br/>"
   PlaceHolder1.Controls.Add(Label1)
   PlaceHolder1.Controls.Add(link)
   PlaceHolder1.Controls.Add(ltr)
   c += 1
   End While
   End Sub

谢谢。

4

1 回答 1

2
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs)
 Dim c As Integer = 0
  While c < 5
   Dim Label1 As New Label()
   Dim ltr As New Literal()     
   Dim link As New HyperLink()
   link.NavigateUrl = "simple.aspx?id=" & c.tostring
   link.BackColor = Drawing.Color.Aqua            
   Label1.Text = c.ToString()
   ltr.Text = "<br/>"
   PlaceHolder1.Controls.Add(Label1)
   PlaceHolder1.Controls.Add(link)
   PlaceHolder1.Controls.Add(ltr)
   c += 1
   End While
   End Sub
于 2010-06-16T23:30:44.307 回答