gridview and sqldatasource - refresh the gridview

P

phil

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
 
P

phil

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)
 
S

Shahzad Godil

Try this

In DataSource_Inserted and DataSource_Updated event

right

Me.GridView.Databind

Shahzad Godil
Karachi-Pakistan.
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,766
Messages
2,569,569
Members
45,042
Latest member
icassiem

Latest Threads

Top