Hi,
I am using 3 Tier architecture.
I have an ASP.net web form with Search button and Gridview.
If I enter studnetId in Textbox and If I click search button,the search result record should be displayed in a gridview below.
Here, I written the code for the search button and the search is working fine and displaying records in Gridview also.
Here my problem is I want the code to be implemented in 3-Layered architecure.
Can anyone tell me the 3 Tier for this example.
protected void btnSearch_Click(object sender, EventArgs e)
{
BindGridView(txtStudentId.Text.Trim());
}
private void BindGridView(string field)
{
DataTable dt = new DataTable();
SqlConnection conn = new SqlConnection("Data Source=.;Initial Catalog=STUDENT;User Id=sa;password=123;Integrated Security=True");
string @DocketId = txtDocketIdSearch.Text;
conn.Open();
SqlCommand comm = new SqlCommand("SELECT studid,studname,studage FROM Student WHERE studid=@studid" , conn);
comm.Parameters.AddWithValue("@studId", @StudId);
SqlDataAdapter da = new SqlDataAdapter(comm);
da.Fill(dt);
SqlParameter param = new SqlParameter();
if (dt.Rows.Count > 0)
{
GridView1.DataSource = dt;
GridView1.DataBind();
}
else
{
Response.Write("No Records....");
}
Please Let me know if my question is not clear...
Thank you,