Textbox's searches Filtered Gridview

This feels like an easy answer but I can't seem to figure it out.  I have a gridview from a SQL datasource linked to a dropdown menu from another SQL source.   The dropdown menu basically filters/populates the gridview according to what I have selected.  I also have 2 textbox's that I want to use to search the gridview SQL datasource, but the search needs to be linked to the selected dropdown item.  So if I have Product ID "10" selected in the dropdown list, I want either textbox to only search this selected ID number. I'm very new to asp.net and don't understand scripting very well yet, so any help would be awesome.

Here's a simple blueprint I created:

 <%@ Page Language="C#" AutoEventWireup="true"  CodeFile="Default.aspx.cs" Inherits="_Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>Untitled Page</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        Search Quantity:
        <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
        &nbsp;Product ID: &nbsp;<asp:DropDownList ID="DropDownList1" runat="server" AutoPostBack="True" DataSourceID="SqlDataSource1"
            DataTextField="ProductID" DataValueField="ProductID">
        </asp:DropDownList>
        &nbsp; &nbsp;Search Discount:
        <asp:TextBox ID="TextBox2" runat="server"></asp:TextBox><br />
        <br />
        <asp:GridView ID="GridView1" runat="server" AllowPaging="True" AllowSorting="True"
            AutoGenerateColumns="False" DataKeyNames="OrderID,ProductID" DataSourceID="SqlDataSource2">
            <Columns>
                <asp:BoundField DataField="OrderID" HeaderText="OrderID" ReadOnly="True" SortExpression="OrderID" />
                <asp:BoundField DataField="ProductID" HeaderText="ProductID" ReadOnly="True" SortExpression="ProductID" />
                <asp:BoundField DataField="UnitPrice" HeaderText="UnitPrice" SortExpression="UnitPrice" />
                <asp:BoundField DataField="Quantity" HeaderText="Quantity" SortExpression="Quantity" />
                <asp:BoundField DataField="Discount" HeaderText="Discount" SortExpression="Discount" />
            </Columns>
        </asp:GridView>
        <asp:SqlDataSource ID="SqlDataSource2" runat="server" ConnectionString="<%$ ConnectionStrings:NorthwindConnectionString %>"
            SelectCommand="SELECT * FROM [Order Details] WHERE ([ProductID] = @ProductID)">
            <SelectParameters>
                <asp:ControlParameter ControlID="DropDownList1" Name="ProductID" PropertyName="SelectedValue"
                    Type="Int32" />
            </SelectParameters>
        </asp:SqlDataSource>
        <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:NorthwindConnectionString %>"
            SelectCommand="SELECT DISTINCT [ProductID] FROM [Products] ORDER BY [ProductID]">
        </asp:SqlDataSource>
        <br />
        <br />
    
    </div>
    </form>
</body>
</html>

0
MaxSwank
3/23/2007 5:50:49 AM
asp.net.object-datasource 16182 articles. 0 followers. Follow

0 Replies
589 Views

Similar Articles

[PageSpeed] 34
Get it on Google Play
Get it on Apple App Store

Reply:

Similar Artilces:

Gridview Search Without Object Datasource Filter ParametersGridview Search Without Object Datasource Filter Parameters
Couple weeks ago I read a article about highlighted search in Gridview  (http://blog.evonet.com.au/post/2008/06/25/Gridview-with-highlighted-search-results.aspx) and in my project I used things I learned but now things changed I have a gridview and in code I give its datasource so because I dont use any objectdatasource I dont know where to write my filtering parameters. Is there anyway to use filtering without objectdatasource, or is there a way to give objectdatasource an source then bind it to my gridview. My code:  //No objectdatasource how can I conduct a search?GridView1.Da...

How to bind GridView's DataSource to an object's List<T> property??
Hi all, I really hope someone has a solution for this. I'm using ObjectDataSource throughout my project. I have an Order class which has, among other properties, a List<Product> ProductList property and a GetProductList method. I use GridView template field to present a list of Orders. For each column, I can, for example, bind a textbox to the OrderID property of my underlying Order object. I can achieve this by simply clicking the textbox's datbindings and associate the Text property to the exposed OrderID field in the underlying Order object. This works fine. I now ...

Ajaxmodalpopup TextBox's --> TEXT--> GridView's TextBox
  Hi I have A Problem With my javascript,   ERROR: 'txtbox1' is undefine in javascript What i want to achieve: I have 1 textbox in my Gridview and i have Modalpopup, i want to transfer data from modalpopup to Gridview's Textbox like User will enter Text into modalpopup's Textbox and Text should go to Gridview's Textbox  for that i have below code:  CODE BEHIND:  For Each gvr As GridViewRow In GridView2.Rows 'Get a programmatic reference to the CheckBox control 'Dim cb As CheckBox = CType(gvr.FindControl("chkBox1"), Ch...

Gridview Search: use DropDownList and TextBox to search / filter gridview?
Let's say I have a gridview with three columns: First Name, Last Name, ID Number.  Here's an example of what I want to do:I want to display all the records in the gridview to start.  There would be a dropdownlist that lets the user select whether to search by first name, last name, or ID number and a text box that lets them type in what they want to search for (and a button to start the search).  After searching, the gridview would only display the records that matched the criteria.The gridview needs to be editable, sortable, and pageable even after searching/filtering...

Replace 1's and 0's in a gridview column with Yes's and No's
Is it possible to change the display of a column in a gridview to show a Yes for all 1's and a No for 0's that display in a particular column of a gridview bound to a database?  If so, can someone share the way with me?  I am using ASP.NET 2.0 with VB Code Behind.  Thanks One way you can do is thrrough  CASE in your select statement: Select YesNoColumn= CASE yourColumn WHEN 1 THEN 'Yes' WHEN 0 THEN 'No' ELSE '' END FROM YourtableLimno <Columns>     <asp:TemplateField HeaderText="yourHeader" SortExpression="yourDataField"> ...

Filtering a gridview with multiple textbox's
i want to be able to filter a gridview with multiple textboxs when searching my website   age between [    ]   to [   ]     state [  ]    zip  [      ] peaple need to be able to enter this info and other s need to zero in on what they are looking for my site is in vb            can someone guide me or direct me to guidence Here's a little guide that you might find helpful: http://www.exforsys.com/tutorials/asp.net-2....

GridView doesn't refresh it's schema after the object data source's GetData() method returns additional fields .
Hi . I am creating an ASP.NET web site and have the following problem :  I have a GridView which bound to the object data source. This object data source is SQL Table adapter that I added to the data set via IDE . The method GetData of this table adapter uses existing stored procedure on my SQL 2005 server. Everything worked fine , until I made a changes to the stored procedure ( the new result records have additional fields )  .  The problem is :   The new fields don’t appear in the grid . Note : When I right click to the GetData method inside the tabl...

obtain ANY control's (textbox/dropdown) value in GridView's HeaderTemplate
Given this templated GridView column containing either Textbox's or DropDownLists......          <asp:TemplateField >              <HeaderTemplate>                      <asp:TextBox ID="TextBoxWellName" runat="server"  Visible="False" l"></asp:TextBox>           &nb...

Gridview Search Without Object Datasource Filter Parameters
Couple weeks ago I read a article about highlighted search in Gridview  (http://blog.evonet.com.au/post/2008/06/25/Gridview-with-highlighted-search-results.aspx) and in my project I used things I learned but now things changed I have a gridview and in code I give its datasource so because I dont use any objectdatasource I dont know where to write my filtering parameters. Is there anyway to use filtering without objectdatasource, or is there a way to give objectdatasource an source then bind it to my gridview. My code:  //No objectdatasource how can I conduct a search?GridView1.Da...

Urgent Help! How to get data from child's gridview to parent's textbox
 Hello Sir,Would you please advise me, how can I get the data from child gridview to parent textbox.For example, I have select 2 row in child's datagrid the values are "A" and "B" then click add and "A B" appears in the same parent's textbox. Thanks in advance!   Anyone please help me. How to get the data from gridview on popup page to textbox on the main page. Thank you so much!!!! Hi Novox , Please check my sample :   <asp:GridView ID="GridView1" runat="server" Height="227px" Width...

Urgent Help! How to get data from child's gridview to parent's textbox #2
 Hello Sir,Would you please advise me, how can I get the data from child gridview to parent textbox?For example, I have select 2 row in child's datagrid the values are "A" and "B" then click add and "A B" appears in the parent's textbox. I think this must use JavaScript to make this happen but I have no idea, please help! Thanks in advance!  parent page : <html xmlns="http://www.w3.org/1999/xhtml" ><head runat="server"> <title>Untitled Page</title></head><body> <form...

What's wrong with DataBind() in GridView control? The data in GridView can't be updated when the datasource have changed!
What's wrong with DataBind() in GridView control? The data in GridView can't be updated when the datasource have changed! I bind the different datasource to the Gridview when I change the node of TreeView, the GridView control always display the same data when I click different the node of TreeView control,why?but I can get the different data in GridView when I click the Button1 or Button2. //-------------------Program Code (You may save it as a ASPX file and run it)--------------------------------<%@ Page Language="C#" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http:/...

First gridview's selected row doesn't update second gridview's objectdatasource
 HelloI got 2 gridviews on a page, each with its own ObjectDataSource. The first gridview fills itself just normally, no problem there. The second gridview needs to fill itself with other data, where the primary key is the primary key of the selected row of the first gridview.schematically:gridview1 row: IDfield, x, y, zrow: IDfield, x, y, z (-> this row is selected)row: IDfield, x, y, z gridview2 row:IDfield_of_selected_row_in_gridview1, a, b, c I tried to do this by configuring the ObjectDataSource behind gridview2 with a parameter pointing to gridview1.selectedValue. (by usin...

Showing GridView's row containing textboxes (all textboxes of the row) yellow when one of the textboxes is selected.
I have a gridview where each row's cells contain textboxes (for providing I/O into the gridview) The problem I need to solve, I think, is with textboxes that make up the cells of the grid. When I select one of the textboxes that make up the cells of the gridview, then I want the whole row, each of the row's textboxes, to be highlighted in yellow showing that row as being selected. Thanks, Steve sholdorf: I have a gridview where each row's cells contain textboxes (for providing I/O into the gridview) The problem I need to solve, I think, is with textboxes that make up the ...

Web resources about - Textbox's searches Filtered Gridview - asp.net.object-datasource

Resources last updated: 12/26/2015 2:34:45 AM