What is the difference between Server.Transfer and
Response.Redirect? Why would you choose one over the other?
Answer Posted / x
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
public partial class _Default : System.Web.UI.Page
{
public SqlDataAdapter dap = null;
public DataSet dst = null;
public string projDesc = string.Empty;
public string divisionName = string.Empty;
protected void Page_Load(object sender, EventArgs e)
{
SqlConnection con = new SqlConnection();
con.ConnectionString =
ConfigurationManager.ConnectionStrings["conString"].ToString
();
con.Open();
string sql = string.Empty;
string projCode = string.Empty;
string divisionCode = string.Empty;
if (!IsPostBack)
{
dap = new SqlDataAdapter("select * from
Project", con);
dst = new DataSet();
dap.Fill(dst);
ddlProject.DataSource = dst;
ddlProject.DataValueField = dst.Tables
[0].Columns["ProjCode"].ToString();
ddlProject.DataTextField = dst.Tables[0].Columns
["ProjDesc"].ToString();
ddlProject.DataBind();
dap.Dispose();
dst.Dispose();
}
projCode = ddlProject.SelectedValue.ToString();
if (Session["projCode"] == null || !projCode.Equals
(Session["projCode"].ToString()))
{
sql = "select * from Division where ProjCode
= " + Convert.ToInt32(projCode);
dap = new SqlDataAdapter(sql, con);
dst = new DataSet();
dap.Fill(dst);
ddlDivision.DataSource = dst;
ddlDivision.DataValueField = dst.Tables
[0].Columns["DivisionID"].ToString();
ddlDivision.DataTextField = dst.Tables
[0].Columns["DivisionName"].ToString();
ddlDivision.DataBind();
dap.Dispose();
dst.Dispose();
Session["projCode"] = projCode;
}
divisionCode = ddlDivision.SelectedValue.ToString();
if (!divisionCode.Equals(string.Empty))
{
sql = "select a.ProjDesc, b.DivisionName,
c.MemberName from Project a inner join Division b on
a.ProjCode = b.ProjCode ";
sql += "inner join Member c on b.DivisionID =
c.DivisionID where a.ProjCode = " + Convert.ToInt32
(projCode);
sql += " and b.DivisionID = " + Convert.ToInt32
(divisionCode);
dap = new SqlDataAdapter(sql, con);
dst = new DataSet();
dap.Fill(dst);
gvProj.DataSource = dst;
gvProj.DataBind();
dap.Dispose();
dst.Dispose();
}
con.Close();
}
protected void gvProj_RowDataBound(object sender,
GridViewRowEventArgs e)
{
gvRowCheck(e);
}
private void gvRowCheck(GridViewRowEventArgs e)
{
if (e.Row.RowIndex == 0)
{
projDesc = e.Row.Cells[0].Text;
divisionName = e.Row.Cells[1].Text;
}
if (e.Row.RowIndex > 0)
{
if (projDesc.Equals(e.Row.Cells[0].Text))
{
e.Row.Cells[0].Text = "";
}
if (divisionName.Equals(e.Row.Cells[1].Text))
{
e.Row.Cells[1].Text = "";
}
}
}
}
| Is This Answer Correct ? | 0 Yes | 0 No |
Post New Answer View All Answers
What do you mean by caching in asp.net?
What are the advantages and disadvantages of session?
Explain client-side scripting?
How to use multiple scriptmanager controls in a web page?
Describe session handling in a webfarm, how does it work and what are the limits?
What is the parent class of all web server control?
Diff between web user control and web custom control?
Explain the differences between clr & cts?
How to use a Master Database in Asp.net?
If we remove web.config or machine.config from the application then, is this application will works?
Explain About duration in caching technique
How to prevent client side validation from the ASP.NET validation controls?
Who can consume WebAPI?
What is Razor View Engine
Describe how passport authentication works.