dear friends i am sory if this is simple or silly question i wanted to know
how to display result in another page
for EX:
index.aspx will have textbox where we enter value and submit button
as soon we click on submit button it should goto result.aspx page and display result.
i want only that code part as i know about sql gridview and button event fire
so please help me with this problem thanks in advance
index.aspx (textbox and button)
result.aspx (result in grid view)
in default.aspx
<form id="form1" runat="server">
<div>
<asp:Label ID="Label1" runat="server" Text="ENTER YOUR STUDENT ID: "
Font-Bold="True" Font-Names="Times New Roman" Font-Size="Small">
<asp:TextBox ID="TextBox1" runat="server">
<asp:Button ID="Button1" runat="server" Text="SUBMIT"
PostBackUrl="~/result.aspx"/><br /><br />
<asp:Label ID="Label2" runat="server" Text="error label">
</div>
</form>
in result.aspx
<form id="form1" runat="server">
<div>
<tr>
<td class="body" border="0" cellspacing="5" cellpadding="5">
<br />
<asp:Label ID="Label3" runat="server" Text="student id" Font-Size="Small">
<br /><br />
<asp:Label ID="Label4" runat="server" Text="student name" Font-Size="Small">
<br /><br />
<asp:Label ID="Label5" runat="server" Text="student class" Font-Size="Small">
<br /><br />
<asp:Label ID="Label6" runat="server" Text="student result" Font-Size="Small">
<br /><br />
</td>
</tr>
<asp:GridView ID="GridView1" runat="server">
<br /><br />
<asp:Label ID="Label2" runat="server" Text="error label">
</div>
</form>
in result.cs
using System;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Data.SqlClient;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (Page.PreviousPage != null)
{
TextBox txt1 = (TextBox)(Page.PreviousPage.FindControl("TextBox1.text"));
}
BindFiles();
}
private void BindFiles()
{
DataTable table = new DataTable();
SqlConnection _conn1 = new SqlConnection(@"conn string");
{
string sql = "select * from studsub where sid=TextBox1";
using (SqlCommand cmd = new SqlCommand(sql, _conn1))
{
using (SqlDataAdapter ad = new SqlDataAdapter(cmd))
{
ad.Fill(table);
}
}
}
GridView1.DataSource = table;
GridView1.DataBind();
}
}
please check my code and tell me where to put which code and what code has to put