AndyPandy
asked on
Databind works most of time, except when "TRACK" is selected
Hi Experts,
How can I fix Gridview1 to show "CNT" (a counter) after the Button "TRACK" is pressed?
Simply in Gridview1:
1) CNT is incremented when the column URL is selected, showing how many times the URL was clicked.
2) TRACK button copies the row into a 2nd table that is the data source for GridView2.
It works fine before "TRACK" is pressed, but not after, even though the SQl table column "CNT" is being updated.
It just doesn't show the updated value of CNT on the screen.
I thought the following should show the updated grid values:
SqlDataSource1.DataBind();
GridView1.DataBind();
But they do not after "TRACK" is pressed.
When the screen is restarted CNT is correct.
grid1.JPG
How can I fix Gridview1 to show "CNT" (a counter) after the Button "TRACK" is pressed?
Simply in Gridview1:
1) CNT is incremented when the column URL is selected, showing how many times the URL was clicked.
2) TRACK button copies the row into a 2nd table that is the data source for GridView2.
It works fine before "TRACK" is pressed, but not after, even though the SQl table column "CNT" is being updated.
It just doesn't show the updated value of CNT on the screen.
I thought the following should show the updated grid values:
SqlDataSource1.DataBind();
GridView1.DataBind();
But they do not after "TRACK" is pressed.
When the screen is restarted CNT is correct.
grid1.JPG
Make sure you disable caching on the SQL Datasource.
ASKER
Hi Strickdd,
I tried EnableCaching= false without luck, see code.
Is this what you meant.
Any other ideas?
Thanks
I tried EnableCaching= false without luck, see code.
Is this what you meant.
Any other ideas?
Thanks
<asp:SqlDataSource ID="SqlDataSource1" runat="server" EnableCaching=false ConnectionString="<%$ ConnectionStrings:CS1 %>"
SelectCommand="SELECT [id], [term], [url], [cnt] FROM [gogetit] ORDER BY [createdate] DESC"></asp:SqlDataSource>
<asp:SqlDataSource ID="SqlDataSource2" runat="server" EnableCaching=false ConnectionString="<%$ ConnectionStrings:CS1 %>"
SelectCommand="SELECT * FROM [gogetit_track] ORDER BY [createdate] DESC"></asp:SqlDataSource>
I don't think it matters, but you should put double quotes around the "false". Also make sure it's not just appending to the gridview by doing a GridView1.Clear() and GridView2.Clear() before their respective databinds.
ASKER
No joy.
There is no Clear for GridView, so GridView1.Clear() gives compile error.Compiler Error Message:
CS1061: 'System.Web.UI.WebControls .GridView' does not contain a definition for 'Clear' and no extension method 'Clear' accepting a first argument of type 'System.Web.UI.WebControls .GridView' could be found (are you missing a using directive or an assembly reference?)
EnableCaching="False" does not seem to have any effect.
There is no Clear for GridView, so GridView1.Clear() gives compile error.Compiler Error Message:
CS1061: 'System.Web.UI.WebControls
EnableCaching="False" does not seem to have any effect.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Response.Redirect(url_temp ,false); changing viewstate is the problem.
ASKER
Open in new window