Solved

GridView Databinding in ASP.Net 2 / VB.NET

Posted on 2006-07-02
3
374 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
ID: 17027451
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
ID: 17028009
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
ID: 17033893
Thanks noulouk - your solution worked fine

Cheers
...Steve
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
DataGridview Currency Formating? 22 53
Disable and re-enable a dynamic System.Timers.Timer 6 41
Closing all open child forms. 4 38
Programmatically signing Word macros 4 61
Introduction As chip makers focus on adding processor cores over increasing clock speed, developers need to utilize the features of modern CPUs.  One of the ways we can do this is by implementing parallel algorithms in our software.   One recent…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
This is used to tweak the memory usage for your computer, it is used for servers more so than workstations but just be careful editing registry settings as it may cause irreversible results. I hold no responsibility for anything you do to the regist…

895 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

15 Experts available now in Live!

Get 1:1 Help Now