-1

i have some different buttons in a page after clicking them i want them to redirect me to a page that has a gridview , but for each button it gives a different gridview which are generated by datatables . may you help to find ,how can i do that in asp.net, vb ?? i did two pages at the gridview page i made methods that are binding different gridviews for each button , and in the first page where i have the button click events i did the redirecting to this gridview page and called the corresponding methods. it redirects me but doen't give me any gridview at all :(

  • 1
    You should provide some code, I think you should research events and delegates, it should help you – Kevin Jul 04 '17 at 08:33

2 Answers2

0

Call in button action

Response.Redirect("Your Page Name.aspx")

and call in that page a BindGrid Function that you create to bind the gridview

AhmadMM
  • 371
  • 4
  • 16
0

You can redirect by using

 Response.Redirect("GridView.aspx")

At the same time you can use only one aspx by using session

Protected Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click

Session.Add("CheckButton", Button1Clicked)
Response.Redirect("GridView.aspx")

End Sub

Protected Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click

Session.Add("CheckButton", Button2Clicked)
Response.Redirect("GridView.aspx")

End Sub

After that at your GridView.aspx on your pageload

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

    Dim CheckButton As String = Session("CheckButton")

    Dim query As String 

    If (CheckButton = "Button1Clicked") Then

    query = "SELECT * FROM Table1"

    Else If (CheckButton = "Button2Clicked") Then

    query = "SELECT * FROM Table2"

    Else

    Response.Write("<script>alert('Error!')</script>")  

    End If

    SqlDataSource1.SelectCommand = query
    SqlDataSource1.DataBind()

    End Sub