Solved

GridView Databinding in ASP.Net 2 / VB.NET

Posted on 2006-07-02
3
371 Views
Last Modified: 2012-05-05
Hi - I am very new to web development, so hopefully the solution to my question is reasonably straightforward.

I have a web page with a reasonably complex search facility on it, due to this complexity I store the results in a temporary table which I then bind bound to a gridview.

In order to get the gridview to refresh and show the search results Ihave to use

gridview.databind()

I have put this in the pageload function, however the gridview always shows me the previous search results. I guess I have the gridview.databind in the wrong place, but I have no ideaw where it should go.

If anyone can shed any light on my problem and point me in the right direction then it would be much appreciated.

Many thanks
...Steve

0
Comment
Question by:swtiley
3 Comments
 
LVL 9

Accepted Solution

by:
noulouk earned 500 total points
Comment Utility
Hi Steve,

Maybe try:
IF NOT Page.IsPostback
gridview.databind()
END IF

This will load your grid the first time.

Then you can use the button click event for example to rebind your gridview.

Hope this helps.
0
 

Expert Comment

by:daforga
Comment Utility
Hi Steve,
You could use a stored procedure as the source of the gridview (or an sql statement). Pass the parameters to call the stored procedure when you fire whatever event you choose to bind data to your gridview.  It could be from a button event, or the SelectedIndexChanged Event od another GridView.   The main thing is, the data must change and you have to tell it what to change to by paramerizing your SQL Calls.
Have fun
daforga
0
 
LVL 1

Author Comment

by:swtiley
Comment Utility
Thanks noulouk - your solution worked fine

Cheers
...Steve
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

This tutorial demonstrates one way to create an application that runs without any Forms but still has a GUI presence via an Icon in the System Tray. The magic lies in Inheriting from the ApplicationContext Class and passing that to Application.Ru…
1.0 - Introduction Converting Visual Basic 6.0 (VB6) to Visual Basic 2008+ (VB.NET). If ever there was a subject full of murkiness and bad decisions, it is this one!   The first problem seems to be that people considering this task of converting…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

762 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now