using controlS to control a gridview

This question is probably posted but i did not bother to look at 10,000+ posts so i am sorry.

 I've seen the tutorial where he builds a dataset and uses a gridview and controls the gridview with the drop down list box. What i am trying to do is to control the gridview with 2 drop down list boxes. First select the Country you life in and then the State. I've looked at the grid view properties but couldn't find where i can add another parameter. Is it possible to control a grid view (or any form of displaying the information) with more than 1 controller?

 

Thank You.
 

0
peteradel
9/5/2007 6:59:07 AM
asp.net.object-datasource 16182 articles. 0 followers. Follow

3 Replies
846 Views

Similar Articles

[PageSpeed] 14

You're quite correct.

This question (or one very similar to it) has been posted and answered before.


Regards

Dave
0
DMW
9/5/2007 8:20:53 AM

Hi,

It seems that you are trying to filter the data in GridView with two parameters, right?

If so, you may try to assign the rowfilter property of DataView with corresponding expression, filter the data in your DataSet. See the following sample:

DataSet myds = new DataSet();
    SqlDataAdapter adpt = null;
    protected void Page_Load(object sender, EventArgs e)
    {
            string conn = ConfigurationManager.ConnectionStrings["connstr"].ConnectionString;
            SqlConnection myconn = new SqlConnection(conn);
            string sql = "select * from Categories";
            adpt = new SqlDataAdapter(sql, conn);

            adpt.Fill(this.myds); //  Fill the data into dataset.
            if (!IsPostBack)
            {
            bind(this.myds.Tables[0].DefaultView); // Bind the GridView.
            }
    }
    public void bind(DataView dv) {
        this.GridView1.DataSource = dv;
        this.GridView1.DataBind();
    }
/// This is the handler for the filter event.
    protected void Button1_Click(object sender, EventArgs e)
    {
        string ar1 = this.DropDownList1.SelectedValue;
        string ar2 = this.DropDownList2.SelectedValue;
        this.myds.Tables[0].DefaultView.RowFilter = "CategoryID='" + ar1 + "' and CategoryName='" + ar2 + "'";
        bind(myds.Tables[0].DefaultView); //  Rebind the GridView.
    }
 Hope that helps.
Michael Jin.
Microsoft Online Community Support

Please remember to mark the replies as answers if they help and unmark them if they provide no help.
0
Nai
9/6/2007 9:15:38 AM

Thank You, that really helped!  Yes
 

0
peteradel
9/6/2007 4:47:46 PM
Reply:

Similar Artilces:

Trying to use the FAQ " Sorting and paging in the GridView control when not using data source controls "Sorting and paging in the GridView control when not using..."
and I am not getting the results I had hoped for.  I keep getting a "Compiler Error Message: CS0123: No overload for 'AdhocJobGridView_PageIndexChanged' matches delegate 'System.EventHandler'".   Here is my event handling... protected void AdhocJobGridView_PageIndexChanged(object sender, GridViewPageEventArgs e){ try { AdhocJobGridView.DataSource = wsBaseInfoArray; AdhocJobGridView.PageIndex = e.NewPageIndex; AdhocJobGridView.DataBind(); }catch (Exception ex) {throw ex; }   Here is my aspx... <asp:GridView ID="AdhocJobGridView...

Custom Datasource Controls Vs. Object Datasource Controls
Hi folks,I am a web developer developing pages in the project. I need to integrate the front end pages with the backend API. Active directory is being used as the database system for our project. I only use the API and the methods offered by it to interact with the data.For all the operations on the data, I have methods that I can call from the API (viz. Create(), Delete(), Modify() etc.). For connecting the data to my frontend data controls (viz. GridView, DropDownList etc.) I can use Object Datasource Control. I also read some articles about Custom Datasource controls. Now, I am having a d...

code for Custom paging without using sqldatasource control and sql datasource control for gridview...........
 code for Custom paging without using sqldatasource control and sql datasource control for gridview...........i need code for how to show all pagenumbers in gridview with custom paging in gridview..............It is very urgent................................. T.Ashok Kumar  suppose that we have a table like thisCountryId  identity intCountryTitle    nvarchar(50)you can use this sql command for paging the dataUSE [CyberOffice]GO/****** Object:  StoredProcedure [dbo].[CountryGetListPaged]    Script Date: 09/17/2008 14:01:06 ******/SET A...

What control do I use (or do I not use a control at all...)
Okay so here's the story so far. I am making a blog to be incorporated into a website. Well, I'm doing the blog from scratch. I'm using MySQL to source all the data via MySQL .NET/Connector. Now while developing the script, I used DataReader and Response.Write to show the blog topics. Now that it has come to put it under a design (I'm using a Master Page for that), I've hit the problem. Response.Write shows all the topics before any of the design elements could be incorporated. So that (more or less) is out of question. So next I looked into the data presentation controls. I looked up GridVi...

Issue with getting values from child controls in a gridview, to use for the update using a SQLDataSource control
Hi all, I have a gridview bound with a SQLDataSource. I am using the Update feature of the SQLDataSource to update a SQL Server database with values entered into the gridview. However I am not getting it to work. I believe this is due to the controls that contain the user entries are not the gridview itself, but rather child controls within the gridview. I have been using the names of the actual controls but nothing happens. Upon submit, the screen returns blank, and the database is not updated. Here is some code:   <asp:GridView ID="GridEditSettlement" runat="server" AutoGenerate...

How to change the SQL used for the GridView, when using a control parameter in the datasource
I'm using a GridVeiw with and Access database. I want to allow users to select a date and then update the GridView to show only data entered after that date. So my question is, how do I modify the SQL used by the datagrid? I'm using a control parameter as part of my AccessDataSource and I think that is what I'm having trouble figuring out how to include. Here is my datasource, with the control parameter in the the GridView. The GridView works fine with these initial settings settings. <asp:AccessDataSource ID="AccessDataSourceForwView" runat="server" ConflictDetection="Compa...

can we use gridview control with in repeater control
HI all,     Can i use gridview control with in repeater control, Any one knows plzzz... let me know. Is there any possibility for this?      It is urgent required... plzzzz... help me..  ------------- ThanksBalu Chandaka  yes you can nest a gridview control in the repeater controlJeev~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~If you get the answer to your question, please mark it as the answer. Hi Jeev,    Thank you for your reply.But how can do that give some idea or If you have any example code snippet then plzzz... let m...

Problem Using Slider Control in Gridview Control
Hello to all,   it is urgent.   i want to use slider control in a Gridview Template Column, if someone can help me how i can get this functionality?...

gridview control in another gridview control
Hi ia have a questioni have a gridview control which contains button in one colum.now my question is i need another gridview to be placed in the  first gidviewso that when i click on the button the second gridview will populate the data.now my question is how to place second gridview in first gridview.or is there any approach like first grid itself acting as parent and child.please help me  Hi sirikalavalapalli:                I think nested gridview will help you. Check this link and it will show you how...

Add new controls to a gridview row; when editing that row using the edit row feature in the gridview control.
Hi all  I have a questions that looks hard / complex to me, and i know you can help me in this. Q {  I have row in a Gridview and i have an edit option to it. I press the edit button, to edit the values in that row and update data all the way back to the database. Now when i press the edit button, i want a drop down list to be displayed that contain values for a particular field in my grid view. (for now only plain text boxes appear.) } I hope you understand my question, all i need to do is replace the text box controls with a dropdown list when i am editing a row in ...

ajax.net controls used in custom composite controls?
I am creating an events calendar that uses the accordion to display the events for the selected day.  The problem I'm having is that the accordion is not responding to any client side events.  I would really like to find a good "How to" article for building composite controls that incorporate an ajax.net control like the accordion....

using a .Net Control as activex control in VCL form
Hi , We have a to integrate a simple .Dot CSharp control which needs to be integrated into bcb2010 VCL form as a control. We will place the control on the VCL form along with other VCL controls's. I tried creating a simple .net control using a lable+textbox and trying to use in vcl form. I have made the assembly comvisible and generated tlb files and .bpl for the component. I could see the component in "ActiveX" tool palette. But when I drag the object onto VCL form and try to access its attributes I run into problems. I am not able to see .net control on the vcl at runti...

Getting the control id of a control inside gridview control
 uhmm.. a little bit confusing regarding my subject because i dont know how to say it...by the way my problem is how can i get the id of a control (e.g. textbox) inside the gridview... and the textbox is in the templatefield... is there any way i can get its id??  hoping i could get a reply as soon as possible... Regards,MhaeyPlease remember to click “Mark as Answer” on the post that helps you.. =) What do you want's to do by getting the id of the Text box? Do you want's to find particular Textbox with certain id ? Kamran ShahidSr. Software Engineer(MCP,MCAD.net,MC...

Problem using two gridviews when using selected value of 1st to control datasource of 2nd
 I have a page with 2 gridviews. When you select a row in the first gridview, the DataKey of that row gets passed to the second gridview, which then displays a list of related records. I've read at http://www.asp.net/learn/data-access/tutorial-08-cs.aspx that there can be issues around page lifecycle timing that can affect what I'm doing so I've tried to follow the instructions there. However, I'm still having problems.Here's the flow of what I want to happen:a) User clicks row in gridview1.b) Postback occurs.c) gridview1 is selected, gridview2 shows records relating...

Web resources about - using controlS to control a gridview - asp.net.object-datasource

Control - Wikipedia, the free encyclopedia
Text is available under the Creative Commons Attribution-ShareAlike License ;additional terms may apply. By using this site, you agree to the ...

China lays out its vision of the internet: more control, more censorship
... censorship of the internet, in a high-profile speech underscoring China's increasingly emphatic attempts to justify its strict online control. ...

Stringify your life by taking control and automating tasks
... Adobe Post or If you can think it, you can create it in Scribblenauts Unlimited . Stringify IF by IFTTT Stringify your life by taking control ...

How to engage Tesla's Launch Control mode
Filed under: Green , Videos , Tesla , Electric Short video shows Model S keeping it straight on a rain-slicked road.

Nuance’s voice control going where Siri, Google Now and Cortana fall short
... for Samsung's S Voice and Apple’s Siri, is ready to go where no other digital assistant has gone before. The company wants to bring voice control ...

EU Acts on Refugees, Terrorism With Tougher Border Controls
Beset by the refugee crisis and fears of terrorism, the European Union floated plans to stiffen its external border controls for Europeans and ...

Apple is about to take even more control
... be about to get tough for some Apple partners as the company invests in top secret display technology development labs and increases its control ...

Google Updates BigQuery With New Cost Controls
Enterprises using BigQuery to run analytics against large data sets can now set a daily query quota on a project-wide or an individual basis. ...

Cancer May Be More Within Our Control Than We Thought
Some cancers may be due to 'bad luck.' But even more of the risk may come from the choices we make every day.

After losing control of Parliament, Venezuelan socialists create a new one
After losing control of Parliament, Venezuelan socialists create a new one

Resources last updated: 12/17/2015 8:43:29 PM