By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
425,810 Members | 818 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 425,810 IT Pros & Developers. It's quick & easy.

gridview and sqldatasource - refresh the gridview

P: n/a
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
Nov 13 '06 #1
Share this Question
Share on Google+
2 Replies


P: n/a
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(IFormatP rovider
provider)
at System.Convert.ChangeType(Object value, TypeCode typeCode,
IFormatProvider provider)
at System.Web.UI.WebControls.Parameter.GetValue(Objec t value, String
defaultValue, TypeCode type, Boolean convertEmptyStringToNull, Boolean
ignoreNullableTypeChanges)
at System.Web.UI.WebControls.Parameter.get_ParameterV alue()
at
System.Web.UI.WebControls.ParameterCollection.GetV alues(HttpContext context,
Control control)
at System.Web.UI.WebControls.SqlDataSource.CreateRawC acheKey()
at System.Web.UI.WebControls.SqlDataSource.CreateCach eKey(Int32
startRowIndex, Int32 maximumRows)
at System.Web.UI.WebControls.SqlDataSource.LoadDataFr omCache(Int32
startRowIndex, Int32 maximumRows)
at
System.Web.UI.WebControls.SqlDataSourceView.Execut eSelect(DataSourceSelectArguments
arguments)
at System.Web.UI.DataSourceView.Select(DataSourceSele ctArguments
arguments, DataSourceViewSelectCallback callback)
at System.Web.UI.WebControls.DataBoundControl.Perform Select()
at System.Web.UI.WebControls.BaseDataBoundControl.Dat aBind()
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.Cal lback(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" <ph**@oakleafsoftware.co.ukwrote in message
news:uv**************@TK2MSFTNGP03.phx.gbl...
>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

Nov 13 '06 #2

P: n/a

Try this

In DataSource_Inserted and DataSource_Updated event

right

Me.GridView.Databind

Shahzad Godil
Karachi-Pakistan.

"phil" <ph**@oakleafsoftware.co.ukwrote in message
news:uR**************@TK2MSFTNGP04.phx.gbl...
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(IFormatP rovider
provider)
at System.Convert.ChangeType(Object value, TypeCode typeCode,
IFormatProvider provider)
at System.Web.UI.WebControls.Parameter.GetValue(Objec t value, String
defaultValue, TypeCode type, Boolean convertEmptyStringToNull, Boolean
ignoreNullableTypeChanges)
at System.Web.UI.WebControls.Parameter.get_ParameterV alue()
at
System.Web.UI.WebControls.ParameterCollection.GetV alues(HttpContext
context, Control control)
at System.Web.UI.WebControls.SqlDataSource.CreateRawC acheKey()
at System.Web.UI.WebControls.SqlDataSource.CreateCach eKey(Int32
startRowIndex, Int32 maximumRows)
at System.Web.UI.WebControls.SqlDataSource.LoadDataFr omCache(Int32
startRowIndex, Int32 maximumRows)
at
System.Web.UI.WebControls.SqlDataSourceView.Execut eSelect(DataSourceSelectArguments
arguments)
at System.Web.UI.DataSourceView.Select(DataSourceSele ctArguments
arguments, DataSourceViewSelectCallback callback)
at System.Web.UI.WebControls.DataBoundControl.Perform Select()
at System.Web.UI.WebControls.BaseDataBoundControl.Dat aBind()
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.Cal lback(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" <ph**@oakleafsoftware.co.ukwrote in message
news:uv**************@TK2MSFTNGP03.phx.gbl...
>>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


Nov 14 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.