Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5989685
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T23:08:13+00:00 2026-05-22T23:08:13+00:00

I have configured a GridView to fill data by an ObjectDataSource . This ObjectDataSource

  • 0

I have configured a GridView to fill data by an ObjectDataSource. This ObjectDataSource requires only one parameter which is bound to a DropDownList. This all works well.

When i load the page, it fills the DropDownList and whatever field is displayed in this DropDownListis passed as a parameter to the ObjectDataSource which further fills the GridView.

Now, i want to enhance the functionality and have a TextBox and Button next to this DropDownList. I want to give my user the option to either select a value from the DropDownList, OR TYPE IT IN THE TextBox AND PRESS ENTER TO UPDATE THE GridView.

Any idea how to do it?

I have tried dataSource.Selecting event. but it isn’t working the way i want it to be.
please help

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T23:08:14+00:00Added an answer on May 22, 2026 at 11:08 pm

    This is a rough sample but basically what you can do is instead of creating a control parameter you can create a session parameter or something similar:

    So when you click enter it will use the textbox value or when you change the dropdownlist it will use the dropdownlist’s value.

    You can also have radio button’s giving the user the option to specify from where he want’s the value.

    <asp:DropDownList ID="ddl" runat="server" AutoPostBack="true" 
            onselectedindexchanged="ddl_SelectedIndexChanged"></asp:DropDownList>
            <asp:TextBox ID="txt" runat="server"></asp:TextBox>
    
            <asp:Button runat="server" Text="ClickMe" ID="btnOne" OnClick="btnOne_Click"/>
    
        <asp:ObjectDataSource ID="ObjectDataSource1" runat="server">
            <SelectParameters>
                <asp:SessionParameter SessionField="ObjectParameterName" />
            </SelectParameters>
        </asp:ObjectDataSource>
    

    Code Behind:

        protected void ddl_SelectedIndexChanged(object sender, EventArgs e)
        {
            var ddl = (DropDownList)sender;
            Session["ObjectParameterName"] = ddl.SelectedValue;
            ObjectDataSource1.Select();
        }
    
        protected void btnOne_Click(object sender, EventArgs e)
        {
            var ddl = (DropDownList)sender;
            Session["ObjectParameterName"] = txt.Text;
            ObjectDataSource1.Select();
        }
    

    EDIT AFTERTHOUGHT

    You can also instead of assigning the parameter to a session field, just set the objectdatasource’s parameter directly (Barring Exception handling).

        protected void ddl_SelectedIndexChanged(object sender, EventArgs e)
        {
            var ddl = (DropDownList)sender;
            ObjectDataSource1.SelectParameters.Add(new Parameter() {Name="Name",DefaultValue=ddl.SelectedValue });
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using Eclipse 3.4 and have configured the Java code formatter with all of
I have a DataGrid which is being bound dynamically to a database query. The
I have a GridView populated from an ObjectDataSource with two items in its DataKeyNames
I have a ListView which is using a GridView to display a DataTable and
I have a page on which I've thrown a LinqDataSource and a GridView. I've
I have configured my application to run using what is described on this thread
i have configured a custom cron in one of my modules, i want it
I have configured Gmail with my MX Domain record. Now where can handle all
I have an IIS-hosted WCF service which is configured to use basicHttpBinding with transport
I have configured 2 connections strings : <connectionStrings> <add name=ApplicationServices connectionString=Data Source=.\SQLInstance;Initial Catalog=App;Integrated Security=True

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.