Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/sql/87.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Sql 使用PostBackUrl ASP.NET动态重定向到另一个页面_Sql_Asp.net_Vb.net_Dynamic_Web Applications - Fatal编程技术网

Sql 使用PostBackUrl ASP.NET动态重定向到另一个页面

Sql 使用PostBackUrl ASP.NET动态重定向到另一个页面,sql,asp.net,vb.net,dynamic,web-applications,Sql,Asp.net,Vb.net,Dynamic,Web Applications,我有一个动态创建的表。此表只有一个字段类别。我从每个类别创建一个按钮。我希望每个按钮都能重定向到特定的页面。每个页面aspx都有一个类别名称.aspx是否有一种方法可以动态执行一次?我使用所选案例创建了此功能,但这不适合我,因为我每次都会创建和删除类别 Using myCommand As New SqlCommand("SELECT kategorie FROM Kategorie", myConn) Using myDataReader As SqlDataReade

我有一个动态创建的表。此表只有一个字段类别。我从每个类别创建一个按钮。我希望每个按钮都能重定向到特定的页面。每个页面aspx都有一个类别名称.aspx是否有一种方法可以动态执行一次?我使用
所选案例创建了此功能,但这不适合我,因为我每次都会创建和删除类别

Using myCommand As New SqlCommand("SELECT kategorie FROM Kategorie", myConn)
            Using myDataReader As SqlDataReader = myCommand.ExecuteReader

                While myDataReader.Read()

                    Dim tRow As New TableRow()
                    tblKategorie.Rows.Add(tRow)

                    Dim tCell As New TableCell()
                    tRow.Cells.Add(tCell)

                    Dim buttKategorie As New Button
                    buttKategorie.Text = myDataReader("kategorie")
                    buttKategorie.CssClass = "buttKategorie"

                    **'Here I tried to do it > ????**
                    'buttKategorie.PostBackUrl = myDataReader("kategorie.aspx")

                    tCell.Controls.Add(buttKategorie)

                End While
            End Using
End Using
XAML:

<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
    <asp:panel runat="server" id="container"></asp:panel>    
</asp:Content>
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
    Dim source As New List(Of String)
    source.Add("page1.aspx")
    source.Add("page2.aspx")
    For Each tmp As String In source
        Dim btn As New Button
        btn.Text = tmp
        btn.ID = tmp
        AddHandler btn.Click, AddressOf Me.Button_Click
        container.Controls.Add(btn)
    Next
End Sub

Private Sub Button_Click(sender As Object, e As EventArgs)
    Dim btn As Button = CType(sender, Button)
    Response.Redirect(btn.Text)
End Sub