?
Solved

GridView Databinding in ASP.Net 2 / VB.NET

Posted on 2006-07-02
3
Medium Priority
?
392 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 9

Accepted Solution

by:
noulouk earned 2000 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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

Well, all of us have seen the multiple EXCEL.EXE's in task manager that won't die even if you call the .close, .dispose methods. Try this method to kill any excels in memory. You can copy the kill function to create a check function and replace the …
I think the Typed DataTable and Typed DataSet are very good options when working with data, but I don't like auto-generated code. First, I create an Abstract Class for my DataTables Common Code.  This class Inherits from DataTable. Also, it can …
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
Suggested Courses
Course of the Month11 days, 10 hours left to enroll

752 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