Submitting forms second time just resets page

S

Steven Reid

Hi All,

I am trying to create a little form where I can enter a SQL query and
return the data in a datagrid. A lot of the times the first time I
open the page and enter a query the datagrid returns data and is fine.
But when I try to resubmit the query or enter another query, the form
just resets and nothing is returned and the form is cleared. I can
use the back button and the sql query statement reappears in the form
but I cant get the form to submit consistantly!


Here is the code to the form

<%@ Page language="c#" Codebehind="RunSQL.aspx.cs"
AutoEventWireup="false" Inherits="Docs.Manager.RunSQL" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
<HEAD>
<title>RunSQL</title>
<meta name="GENERATOR" Content="Microsoft Visual Studio 7.0">
<meta name="CODE_LANGUAGE" Content="C#">
<meta name=vs_defaultClientScript content="JavaScript">
<meta name=vs_targetSchema
content="http://schemas.microsoft.com/intellisense/ie5">
</HEAD>
<body MS_POSITIONING="GridLayout">
<form id="RunSQL" method="post" runat="server">
<a href="runsql.aspx">RESET</a><br>
<asp:Label ID="lMessage" Runat=server>Before Run
Script</asp:Label><br>
<asp:TextBox id=TextBox1 runat="server" Width="354px"
Height="207px" TextMode="MultiLine"></asp:TextBox><br>
<asp:Button id=Button1 runat="server" Width="353px" Height="28px"
Text="Run"></asp:Button><br>
<asp:DataGrid id=DataGrid1 runat="server" Width="352px"
Height="163px"></asp:DataGrid><br>

</form>

</body>
</HTML>



Thanks

Steven Reid
 
R

R. Thomas, aka Xtreme.Net

When you say that the form is cleared, do you mean the controls dissapear? or
that the datagrid is empty?
R. Thomas
 
S

Steve Reid

Hi,

There is currently a text box (where you can enter the sql statement)
and a submit button on the page.

The expected action is that when you type in a SQL statement and click
submit, the results appear in the datagrid below. If you enter another
SQL Query then the new results appear in the datagrid below.

What is currently happening is that 'sometimes' on the first time on the
page, the above happens.....
but often all that happens when I click the submit button is that the
progesss bar on the status line appears starts moving, then the text box
gets cleared, and no data appears in the datagrid area.

If I DO manage to get the datagrid to appear... if I try to submit a
second query, then the text area gets cleared and no data appears.

Thanks

Steve
 
R

R. Thomas, aka Xtreme.Net

Cant say much like this.. you have to debug and see whats happening...
However few pointers :
Check if the binding takes place EVERY time
Check if the data is retrieved from the db EVERY time
Hth...
R. Thomas
 
R

R. Thomas, aka Xtreme.Net

If you just step thru it while debugging, you'll know all the previous
mentioned info. Then you'll know where is the problem occuring..
Hth...
R. Thomas
 
S

Steve Kirchner

Hey if try wrapping you on page load event with these two lines of code.


If Not IsPostBack Then

End if

The "not ispostback" determine if the page is being opened for the first time or if it is being re-submitted.

Give it a try

Posted via DevelopmentNow Group
www.developmentnow.com/
www.developmentnow.com
 

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,744
Messages
2,569,483
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top