
using System;
using System.Collections;
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 Default2 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
SqlConnection con = new SqlConnection("Data Source=ORCHE5;Initial Catalog=test;Integrated Security=True;Password=sqlserver2005");
SqlDataAdapter adp = new SqlDataAdapter("prc_search", con);
adp.SelectCommand.CommandType = CommandType.StoredProcedure;
if (TextBox1.Text == "")
{
adp.SelectCommand.Parameters.Add(new SqlParameter("@TextBox1", System.Data.SqlDbType.Int));
adp.SelectCommand.Parameters["@textBox1"].Value = 0;
DataSet ds = new DataSet();
adp.Fill(ds);
if (ds.Tables[0].Rows.Count > 0)
{
GridView1.DataSource = ds.Tables[0];
GridView1.DataBind();
GridView1.Visible = true;
TextBox2.Text = "";
TextBox3.Text = "";
}
else
{
Label4.Visible = true;
Label4.Text = "Record not Found";
}
}
else
{
adp.SelectCommand.Parameters.Add(new SqlParameter("@TextBox1", System.Data.SqlDbType.Int));
adp.SelectCommand.Parameters["@textBox1"].Value = Convert.ToInt32(TextBox1.Text);
DataSet ds = new DataSet();
adp.Fill(ds);
if (ds.Tables[0].Rows.Count > 0)
{
TextBox2.Text = ds.Tables[0].Rows[0]["emp_name"].ToString();
TextBox3.Text = ds.Tables[0].Rows[0]["mob_no"].ToString();
GridView1.DataSource = null;
GridView1.Visible = false;
}
else
{
Label4.Visible = true;
Label4.Text = "Record not Found";
}
}
}
}
jitendra kumar mahapatro
Jiturcm, if this helps please login to Mark As Answer. | Alert Moderator