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

Related Questions

I have an ObjectDataSource that is binding to my GridView just fine. I also
If I have the following (generic) ASP code: <asp:ObjectDataSource runat=server ID=myODS>...</asp:ObjectDataSource> <asp:GridView runat=server ID=myGV
I have a Gridview which binds to an ObjectDataSource (objStudentDetails). In edit/insert mode of
I have a gridview with an ObjectDataSource which I want to update with one
I have the following GridView and ObjectDataSource: <asp:GridView ID=grdTrades runat=server DataSourceID=srcTrades DataKeyNames=tradeId EnablePersistedSelection=true SelectedRowStyle-BackColor=Yellow
I have a gridview that is bound to an ObjectDataSource, which retrieves records from
I have an objectdatasource which i want to bind to a repeater. the problem
I have a GridView connected to an ObjectDataSource which does the sorting/paging in codebehind.
If I have an ObjectDataSource defined at design time, can I get a DataTable
I have a GridView populated from an ObjectDataSource with two items in its DataKeyNames

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.