[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Creating ASPGrid  at run time

Posted on 2009-02-10
1
Medium Priority
?
161 Views
Last Modified: 2012-05-06
I have a web form that display the data grid. The data grid is bound to a stored procedure based on the criteria being passed.
I am no problem when i invoke the method that binds the data grid for the first time.(ie when i pass the parameter)

Now when i pass a different value to the parameter, i need the grid to show results that where passed as parameter on FIRST EXECUTION.

I can easily have 2 data grid to accomplish this. But if i am not sure how many times the paramter would be changed , how do i accomplish showing the datagrid with results based on the criteria being passed.
Attached are my methods i am using.
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        Try
 
              'Loop through the search request and show search results for each request
            Dim aList, x
            If Len(Request.QueryString("RefID")) > 0 Then
                aList = Split(Request.QueryString("RefID"), "*~*")
                For x = 0 To UBound(aList)
                    BindGrid(CInt(aList(x)))
                Next
            End If
 
 
        Catch ex As Exception
 
        End Try
    End Sub
 
Sub BindGrid(ByVal iSearchID As Integer)
        Try
 
            Dim objSearchResults As New CommuterDALTableAdapters.objCommuterSearchRequestReportsTableAdapter
            dgGrid.DataSource = objSearchResults.FetchSearchMatches(iSearchID)
            dgGrid.DataBind()
 
        Catch ex As Exception
 
          
        End Try
    End Sub

Open in new window

0
Comment
Question by:TECH_NET
1 Comment
 
LVL 12

Accepted Solution

by:
CB_Thirumalai earned 1500 total points
ID: 23607147
How you want to pass the parameter after the first time?  You do a post-back, by having as
     <asp:Button ID="button" runat="server" OnClick="button_Click" />
and in the code behind, have this method
     Protected Sub button_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles button.Click
             ' Access the parameter and pass to the BindGrid
     End Sub

Also, surround the code in the Page_Load only to fire if the page is NOT postback as

If Not IsPostBack Then
              'Loop through the search request and show search results for each request
            Dim aList, x
            If Len(Request.QueryString("RefID")) > 0 Then
                aList = Split(Request.QueryString("RefID"), "*~*")
                For x = 0 To UBound(aList)
                    BindGrid(CInt(aList(x)))
                Next
            End If
End If
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
IntroductionWhile developing web applications, a single page might contain many regions and each region might contain many number of controls with the capability to perform  postback. Many times you might need to perform some action on an ASP.NET po…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an anti-spam), the admin…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
Suggested Courses
Course of the Month19 days, 11 hours left to enroll

872 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question