gridview and sqldatasource - refresh the gridview

Discussion in 'ASP .Net' started by phil, Nov 13, 2006.

  1. phil

    phil Guest

    I have an ASP.NET application with an SQLdataSource and a Gridview

    Everything works very well except I have a 'Button' that goes off and
    changes some of the record data back in the underlying database records.
    When I press this the data is definitely changed in the database - but on
    screen nothing seems to happen.


    So how do I force the page to reload the records from the database and
    populate the gridview.

    I'm not worried about any performance issues I just want to make sure the
    real data is on display all the time

    (If I restart the app the records are displayed properly)

    If anyone can help on this I'd be very grateful

    All the best
    Phil
     
    phil, Nov 13, 2006
    #1
    1. Advertising

  2. phil

    phil Guest

    I've just tried setting calling the DataBind method of the gridview in the
    PreRenderComplete procedure

    I was assuming that it would simply use the sqldatsource that it was set up
    with but when I call DataBind I get the following exception

    oh boy.....
    Phil

    System.FormatException was unhandled by user code
    Message="Input string was not in a correct format."
    Source="mscorlib"
    StackTrace:
    at System.Number.StringToNumber(String str, NumberStyles options,
    NumberBuffer& number, NumberFormatInfo info, Boolean parseDecimal)
    at System.Number.ParseInt64(String value, NumberStyles options,
    NumberFormatInfo numfmt)
    at System.String.System.IConvertible.ToInt64(IFormatProvider
    provider)
    at System.Convert.ChangeType(Object value, TypeCode typeCode,
    IFormatProvider provider)
    at System.Web.UI.WebControls.Parameter.GetValue(Object value, String
    defaultValue, TypeCode type, Boolean convertEmptyStringToNull, Boolean
    ignoreNullableTypeChanges)
    at System.Web.UI.WebControls.Parameter.get_ParameterValue()
    at
    System.Web.UI.WebControls.ParameterCollection.GetValues(HttpContext context,
    Control control)
    at System.Web.UI.WebControls.SqlDataSource.CreateRawCacheKey()
    at System.Web.UI.WebControls.SqlDataSource.CreateCacheKey(Int32
    startRowIndex, Int32 maximumRows)
    at System.Web.UI.WebControls.SqlDataSource.LoadDataFromCache(Int32
    startRowIndex, Int32 maximumRows)
    at
    System.Web.UI.WebControls.SqlDataSourceView.ExecuteSelect(DataSourceSelectArguments
    arguments)
    at System.Web.UI.DataSourceView.Select(DataSourceSelectArguments
    arguments, DataSourceViewSelectCallback callback)
    at System.Web.UI.WebControls.DataBoundControl.PerformSelect()
    at System.Web.UI.WebControls.BaseDataBoundControl.DataBind()
    at System.Web.UI.WebControls.GridView.DataBind()
    at ASP.eoltest_aspx.Page_PreRenderComplete(Object sender, EventArgs
    e) in C:\CallidusWorld\eolTest.aspx:line 71
    at System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp,
    Object o, Object t, EventArgs e)
    at System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object
    sender, EventArgs e)
    at System.Web.UI.Page.OnPreRenderComplete(EventArgs e)
    at System.Web.UI.Page.PerformPreRenderComplete()
    at System.Web.UI.Page.ProcessRequestMain(Boolean
    includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)


    "phil" <> wrote in message
    news:...
    >I have an ASP.NET application with an SQLdataSource and a Gridview
    >
    > Everything works very well except I have a 'Button' that goes off and
    > changes some of the record data back in the underlying database records.
    > When I press this the data is definitely changed in the database - but on
    > screen nothing seems to happen.
    >
    >
    > So how do I force the page to reload the records from the database and
    > populate the gridview.
    >
    > I'm not worried about any performance issues I just want to make sure the
    > real data is on display all the time
    >
    > (If I restart the app the records are displayed properly)
    >
    > If anyone can help on this I'd be very grateful
    >
    > All the best
    > Phil
    >
     
    phil, Nov 13, 2006
    #2
    1. Advertising

  3. Try this

    In DataSource_Inserted and DataSource_Updated event

    right

    Me.GridView.Databind

    Shahzad Godil
    Karachi-Pakistan.

    "phil" <> wrote in message
    news:...
    > I've just tried setting calling the DataBind method of the gridview in the
    > PreRenderComplete procedure
    >
    > I was assuming that it would simply use the sqldatsource that it was set
    > up with but when I call DataBind I get the following exception
    >
    > oh boy.....
    > Phil
    >
    > System.FormatException was unhandled by user code
    > Message="Input string was not in a correct format."
    > Source="mscorlib"
    > StackTrace:
    > at System.Number.StringToNumber(String str, NumberStyles options,
    > NumberBuffer& number, NumberFormatInfo info, Boolean parseDecimal)
    > at System.Number.ParseInt64(String value, NumberStyles options,
    > NumberFormatInfo numfmt)
    > at System.String.System.IConvertible.ToInt64(IFormatProvider
    > provider)
    > at System.Convert.ChangeType(Object value, TypeCode typeCode,
    > IFormatProvider provider)
    > at System.Web.UI.WebControls.Parameter.GetValue(Object value, String
    > defaultValue, TypeCode type, Boolean convertEmptyStringToNull, Boolean
    > ignoreNullableTypeChanges)
    > at System.Web.UI.WebControls.Parameter.get_ParameterValue()
    > at
    > System.Web.UI.WebControls.ParameterCollection.GetValues(HttpContext
    > context, Control control)
    > at System.Web.UI.WebControls.SqlDataSource.CreateRawCacheKey()
    > at System.Web.UI.WebControls.SqlDataSource.CreateCacheKey(Int32
    > startRowIndex, Int32 maximumRows)
    > at System.Web.UI.WebControls.SqlDataSource.LoadDataFromCache(Int32
    > startRowIndex, Int32 maximumRows)
    > at
    > System.Web.UI.WebControls.SqlDataSourceView.ExecuteSelect(DataSourceSelectArguments
    > arguments)
    > at System.Web.UI.DataSourceView.Select(DataSourceSelectArguments
    > arguments, DataSourceViewSelectCallback callback)
    > at System.Web.UI.WebControls.DataBoundControl.PerformSelect()
    > at System.Web.UI.WebControls.BaseDataBoundControl.DataBind()
    > at System.Web.UI.WebControls.GridView.DataBind()
    > at ASP.eoltest_aspx.Page_PreRenderComplete(Object sender, EventArgs
    > e) in C:\CallidusWorld\eolTest.aspx:line 71
    > at System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp,
    > Object o, Object t, EventArgs e)
    > at System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object
    > sender, EventArgs e)
    > at System.Web.UI.Page.OnPreRenderComplete(EventArgs e)
    > at System.Web.UI.Page.PerformPreRenderComplete()
    > at System.Web.UI.Page.ProcessRequestMain(Boolean
    > includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
    >
    >
    > "phil" <> wrote in message
    > news:...
    >>I have an ASP.NET application with an SQLdataSource and a Gridview
    >>
    >> Everything works very well except I have a 'Button' that goes off and
    >> changes some of the record data back in the underlying database records.
    >> When I press this the data is definitely changed in the database - but on
    >> screen nothing seems to happen.
    >>
    >>
    >> So how do I force the page to reload the records from the database and
    >> populate the gridview.
    >>
    >> I'm not worried about any performance issues I just want to make sure the
    >> real data is on display all the time
    >>
    >> (If I restart the app the records are displayed properly)
    >>
    >> If anyone can help on this I'd be very grateful
    >>
    >> All the best
    >> Phil
    >>

    >
    >
     
    Shahzad Godil, Nov 14, 2006
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. brian lanning
    Replies:
    0
    Views:
    629
    brian lanning
    Jul 29, 2003
  2. Per Magnus L?vold
    Replies:
    1
    Views:
    5,210
    John C. Bollinger
    Oct 8, 2004
  3. Andrea Raimondi
    Replies:
    2
    Views:
    953
    Eliyahu Goldin
    Jul 13, 2008
  4. Pkenty
    Replies:
    0
    Views:
    434
    Pkenty
    May 28, 2004
  5. Jawahar Rajan
    Replies:
    1
    Views:
    309
    Adrienne
    Oct 1, 2003
Loading...

Share This Page