Solved

GridView Databinding in ASP.Net 2 / VB.NET

Posted on 2006-07-02
3
382 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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
VB.NET 2008 (3.5 Framework) Remove all items from List 3 32
vb.net winforms sizing/resolution? 4 40
Generate Numbers in JQuery file 11 66
System.net.Sockets Error 5 26
If you're writing a .NET application to connect to an Access .mdb database and use pre-existing queries that require parameters, you've come to the right place! Let's say the pre-existing query(qryCust) in Access takes a Date as a parameter and l…
A while ago, I was working on a Windows Forms application and I needed a special label control with reflection (glass) effect to show some titles in a stylish way. I've always enjoyed working with graphics, but it's never too clever to re-invent …
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

808 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