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

  • Home
  • SEARCH
  • 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 66799
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T19:09:36+00:00 2026-05-10T19:09:36+00:00

I have an ObjectDataSource with an ID of ObjectDataSource1 on a webpage. I also

  • 0

I have an ObjectDataSource with an ID of ObjectDataSource1 on a webpage. I also have a gridview in which I am binding the ObjectDataSource.ID to the GridView.DataSourceID. The problem I get is when text is changed in a textbox, the code calls BrokerageTransactions.GetAllWithDt which returns a DataTable. I want to set this datatable as the DataSource for the GridView, but it is telling me that I can’t set the DataSouce and DataSourceId together. How can I fix this? Code is below. Also. Why can’t you set a DataSourceID and a DataSource when using an ObjectDataSource?

Thanks, X

protected void BrokerageChange(Object sender, EventArgs e) {     BrokerageTransactions brokerageaccountdetails =                            new BrokerageTransactions();      DataSet ds = BrokerageAccount.GetBrkID2(new                   Guid(Membership.GetUser().ProviderUserKey.ToString()),                   ddlBrokerageDetails.SelectedItem.Text.ToString());      foreach (DataRow dr in ds.Tables[0].Rows)     {         brokerageaccountdetails.BrokerageId =                                  new Guid(dr['BrkrgId'].ToString());     }      ddlBrokerageDetails.SelectedItem.Value =                          brokerageaccountdetails.BrokerageId.ToString();      if (txtTransactionsTo.Text != ''          && txtTransactionsFrom.Text != '')         ObjectDataSource1.FilterExpression =          'convert(CreateDt,System.DateTime)>Convert('' +           Convert.ToDateTime(txtTransactionsFrom.Text) + '',System.DateTime)           and Convert(CreateDt,System.DateTime)<convert(''          + Convert.ToDateTime(txtTransactionsTo.Text.ToString()) +           '',System.DateTime)';     else if (txtTransactionsFrom.Text != '')             ObjectDataSource1.FilterExpression =             'convert(CreateDt,System.DateTime)>convert('' +              Convert.ToDateTime(txtTransactionsFrom.Text) +              '',System.DateTime)';     else if (txtTransactionsTo.Text != '')             ObjectDataSource1.FilterExpression =              'convert(CreateDt,System.DateTime)             <convert(''              + Convert.ToDateTime(txtTransactionsTo.Text.ToString()) +               '',System.DateTime)';     else         ObjectDataSource1.FilterExpression = ' ';      grvBrokerage.DataSourceID = ObjectDataSource1.ID;     grvBrokerage.DataBind();      DateTime dtTransFrom = Convert.ToDateTime('1/1/1900');     DateTime dtTransTo = System.DateTime.Today;      //TransactionsTo Box is Empty     if ((txtTransactionsFrom.Text.Length > 2)      && (txtTransactionsTo.Text.Length < 2))      {         dtTransFrom = Convert.ToDateTime(txtTransactionsFrom.Text);         dtTransTo = System.DateTime.Today;     }      //TransactionsFrom Box is Empty     if ((txtTransactionsFrom.Text.Length < 2)      && (txtTransactionsTo.Text.Length > 2))     {        dtTransFrom = Convert.ToDateTime('1/1/1900');        dtTransTo = Convert.ToDateTime(txtTransactionsTo.Text);     }      //TransactionsFrom Box and TransactionsTo Box is Not Empty     if ((txtTransactionsFrom.Text.Length > 2)      && (txtTransactionsTo.Text.Length > 2))     {         dtTransFrom = Convert.ToDateTime(txtTransactionsFrom.Text);         dtTransTo = Convert.ToDateTime(txtTransactionsTo.Text);     }     // Fails Here     grvBrokerage.DataSource =      BrokerageTransactions.GetAllWithDt(brokerageaccountdetails.BrokerageId,                                         dtTransFrom,                                         dtTransTo);     grvBrokerage.DataBind();  } 
  • 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. 2026-05-10T19:09:36+00:00Added an answer on May 10, 2026 at 7:09 pm

    You got 2 options:

    • Do not use the ObjectDataSource at all. You just use the DataSource property and Set It grammatically every time.
    • You use the DataSourceID property of the GridView and Add 2 plain asp:Parameters with default value set. On the ObjectDataSource_Selecting Event you set these parameters through e.InputParameters[]

    Hope this helps.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 142k
  • Answers 142k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer It is neither. It runs on the same UI thread… May 12, 2026 at 8:12 am
  • Editorial Team
    Editorial Team added an answer There's nothing wrong with having an ajax call inside an… May 12, 2026 at 8:12 am
  • Editorial Team
    Editorial Team added an answer First way using union: select 'AD' union all select 'AE'… May 12, 2026 at 8:12 am

Related Questions

I have a repeater control on an ASP.NET 2.0 web form. As I understanding
I have a GridView which I am populating by calling a method to return
I'd like the community's take on some thoughts I've had about Linq to Sql
I've made a small example with a Person class, which contains a list of

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.