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 3359284
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T02:51:13+00:00 2026-05-18T02:51:13+00:00

I have a GridView and when some data has been inserted I have called

  • 0

I have a GridView and when some data has been inserted I have called the DataBind() method on the GridView and the ObjectDataSource the GridView is bound to, but the GridView does not display the new data. How do I get it to refresh?

Here’s my ASP.NET code:

<asp:GridView 
    ID="grdOrderSignals" 
    runat="server" 
    DataSourceID="srcOrderSignals" 
    DataKeyNames="signal"
    EmptyDataText="There are no signals for this order"
    AutoGenerateColumns="False">
    <Columns>
        <asp:BoundField DataField="signal" HeaderText="Signal Id"  ReadOnly="True" />
        <asp:BoundField DataField="description" HeaderText="Description"  ReadOnly="True" />
        <CustomControls:DeleteButtonField ConfirmText="Delete this order signal?" Text="Del" />
    </Columns>
</asp:GridView>  

<CustomControls:CustomObjectDataSource
    id="srcOrderSignals" 
    TypeName="DatabaseComponent.DBUtil" 
    SelectMethod="GetOrderSignals" 
    DeleteMethod="DeleteOrderSignal" 
    EnableCaching="false"

    runat="server">
    <SelectParameters>
        <asp:ControlParameter Name="orderId" ControlID="grdOrders" PropertyName="SelectedValue" />
    </SelectParameters> 
    <DeleteParameters>
        <asp:ControlParameter Name="orderId" ControlID="grdOrders" PropertyName="SelectedValue" />        
        <asp:ControlParameter Name="signal" ControlID="grdOrderSignals" PropertyName="SelectedValue" />                    
    </DeleteParameters>           
</CustomControls:CustomObjectDataSource> 

<asp:Button ID="btnAddOrderSignal" runat="server" Text="Add Order Signal" OnClick="btnAddOrderSignal_Click" />
<asp:DropDownList ID="ddlSignals" runat="server" Visible="false" />
<asp:Button ID="btnInsertOrderSignal" runat="server" Text="Add" Visible="false" OnClick="btnInsertOrderSignal_Click" />

Here’s my code-behind to handle the click events:

protected void btnAddOrderSignal_Click(object sender, EventArgs e)
{
    FillSignals();
    btnAddOrderSignal.Visible = false;
    ddlSignals.Visible = true;
    btnInsertOrderSignal.Visible = true;

}

protected void btnInsertOrderSignal_Click(object sender, EventArgs e)
{
    InsertOrderSignal();
    btnAddOrderSignal.Visible = true;
    ddlSignals.Visible = false;
    btnInsertOrderSignal.Visible = false;
    srcOrderSignals.DataBind();
    grdOrderSignals.DataBind();      
}

protected void InsertOrderSignal()
{
    DBUtil DB = new DBUtil();
    int orderId = (int)grdOrders.SelectedValue;
    string signalId = ddlSignals.SelectedValue;
    DB.InsertOrderSignal(orderId, signalId);
}

protected void FillSignals()
{
    DBUtil DB = new DBUtil();
    DataTable od = DB.GetOrderDetails((int)grdOrders.SelectedValue);
    int strategyId = (int)od.Rows[0]["strategyId"];

    ddlSignals.DataSource = DB.GetSignals(strategyId);
    ddlSignals.DataTextField = "signalId";
    ddlSignals.DataValueField = "signalId";
    ddlSignals.DataBind();      
}

Do I need to call DataBind() on both objects? What have I done wrong here?

Thanks!

  • 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-18T02:51:14+00:00Added an answer on May 18, 2026 at 2:51 am

    In your method btnInsertOrderSignal_Click you are adding a new item and databinding again. This is correct but you are not updating your datasource before databinding(). This means that it will bind to the original datasource.

    It seems that what populates your CustomControl needs to be called again. GetOrderSignals()?

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

Sidebar

Related Questions

I have a GridView with some data and a pager so that I don't
I have been playing around with the WPF GridView control (DesktopUI not Silverlight) and
i want to display some information in a listview using the GridView. i have
I have a GridView control in an Asp.net application, that has a <asp:buttonField> of
I have a GridView where one column is bound to an object property containing
I have a GridView that I would like to bind to an ObjectDataSource. I
I have a GridView populated from an ObjectDataSource with two items in its DataKeyNames
I've been thrown a project which I have to say I've not got the
I have a basic DropDownList bound to a ObjectDataSource: <asp:DropDownList ID=DropDownList1 runat=server AutoPostBack=True DataSourceID=objDataSource1
I have created a gridview in code behind (as in its not physically present

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.