[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

how to repopulate a Gridveiw when using parameters

Posted on 2008-06-11
3
Medium Priority
?
268 Views
Last Modified: 2013-11-26
Hi,

in my asp.net project i have placed a text box, a button, and a gridview.
I will enter some text on the text box and click the button. The button should run the query " select * from table where value=something" and populate the grid view. I dont know how to do this.

Any examples or links to read on will be very helpful ?

i can get the grid to display All of the data.. but i want after the page loads, i insert my own filter and re-populate the grid...

I am using VB Studion 2005 standart, asp.net website project and vb language.

0
Comment
Question by:Wizilling
[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
  • 2
3 Comments
 
LVL 11

Accepted Solution

by:
Anurag Agarwal earned 1200 total points
ID: 21766007
Currently you must be loading your grid in page load function.

Put this code in

If(NOT IsPostBack) Then
       LoadGrid('Default load condition')
End IF

Also make a function for the logic of populating the grid starting from making the query & database hit & setting the datasource of grid. Function should be like

Public Sub LoadGrid(ByVal whereCondition as String)
--
--
End Sub

Now call this function from page load when page loaded for first time with default where condition i.e. condition to load grid for first time.

On button click event call this function LoadGrid('textbox value') . this will repopulate the grid with your filter.

Let me know if you face any problem implementing this.

Anurag
0
 
LVL 5

Expert Comment

by:Qaiser_Mehmood_Mughal
ID: 21766568
this is the one way, create a method and pass the query based on ur requirment and the get the dataset and then bound this dataset to gridview again.    

    protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                LoadData("Select * from customers");
            }
        }

        private DataSet LoadData(string strQuery)
        {
            DataSet objDataSet=new DataSet();
            // Use the SQLCommand to fill the data set
            return objDataSet;
        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            LoadData("Select * from customers where customerName='" + txtName + "'");
        }
0
 
LVL 5

Assisted Solution

by:Qaiser_Mehmood_Mughal
Qaiser_Mehmood_Mughal earned 800 total points
ID: 21766589
The Second option is to get the default view of your dataset object which is going to bound and then filter this object as many time as you want, based on the search criteria.

                DataSet objDataSet = new DataSet();
                DataView dv= objDataSet.Tables[0].DefaultView;
                // For DV, you can use following methods for seach.
                //dv.RowFilter
                //dv.Find();
                //dv.FindRows();
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering 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

A quick way to get a menu to work on our website, is using the Menu control and assign it to a web.sitemap using SiteMapDataSource. Example of web.sitemap file: (CODE) Sample code to add to the page menu: (CODE) Running the application, we wi…
For those of you who don't follow the news, or just happen to live under rocks, Microsoft Research released a beta SDK (http://www.microsoft.com/en-us/download/details.aspx?id=27876) for the Xbox 360 Kinect. If you don't know what a Kinect is (http:…
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
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. …

649 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