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. Advertisements

  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. Advertisements

  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. Advertisements

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. =?Utf-8?B?UA==?=
    Replies:
    1
    Views:
    2,395
    Michelle Hlaing
    Nov 30, 2004
  2. Henry Habermacher [MVP Access]

    GridView - Changing FilterExpression of SQLDataSource and Paging

    Henry Habermacher [MVP Access], Jan 20, 2006, in forum: ASP .Net
    Replies:
    2
    Views:
    11,722
    kmarchiony
    Jul 31, 2007
  3. =?Utf-8?B?RGFiYmxlcg==?=

    insert row using Gridview and SqlDataSource?

    =?Utf-8?B?RGFiYmxlcg==?=, Mar 19, 2006, in forum: ASP .Net
    Replies:
    2
    Views:
    10,868
    =?Utf-8?B?RGFiYmxlcg==?=
    Mar 20, 2006
  4. =?Utf-8?B?RG9ydGU=?=

    Gridview and SqlDatasource from code behind

    =?Utf-8?B?RG9ydGU=?=, Mar 30, 2006, in forum: ASP .Net
    Replies:
    3
    Views:
    25,211
    =?Utf-8?B?Y2xpY2tvbg==?=
    Mar 30, 2006
  5. Michael Kellogg
    Replies:
    0
    Views:
    955
    Michael Kellogg
    Apr 6, 2006
  6. Mike P

    SqlDataSource and GridView

    Mike P, May 31, 2006, in forum: ASP .Net
    Replies:
    2
    Views:
    8,839
    kshashank
    Dec 27, 2010
  7. =?Utf-8?B?bmF0ZQ==?=

    sqldatasource and gridview problem

    =?Utf-8?B?bmF0ZQ==?=, Aug 29, 2006, in forum: ASP .Net
    Replies:
    1
    Views:
    2,284
    =?Utf-8?B?bmF0ZQ==?=
    Aug 29, 2006
  8. Andrea Raimondi
    Replies:
    2
    Views:
    1,070
    Eliyahu Goldin
    Jul 13, 2008
Loading...