I have a problem in 3-Layer Architecture in asp.net

Posted by Nuwan under C# on 12/29/2011 | Points: 10 | Views : 1240 | Status : [Member] | Replies : 5
Hello Dear,
I want to know how to do Search function using three tier architecture.

Rathnayake


Responses

Posted by: Vuyiswamb on: 12/30/2011 [Member] [MVP] [Administrator] NotApplicable | Points: 25

Up
0
Down
Look at how i did it here

http://www.codeproject.com/KB/vb/N-Tier_Application_VB.aspx

Thank you for posting at Dotnetfunda
[Administrator]

Nuwan, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Nuwan on: 12/31/2011 [Member] Starter | Points: 25

Up
0
Down
Dear Sir,
Thank you for your posting. I want to know it without grid view, like retrieve data inside a textbox


Thank You.

Rathnayake

Nuwan, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Vuyiswamb on: 12/31/2011 [Member] [MVP] [Administrator] NotApplicable | Points: 25

Up
0
Down
Want to search Data and bind textboxes ? if yes the approach is the same , because a grid is bound with a datatable, just get the column you need and bid i to the textbox

Thank you for posting at Dotnetfunda
[Administrator]

Nuwan, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Self-innovator on: 1/1/2012 [Member] Bronze | Points: 25

Up
0
Down

Try like this hope it wil use
THREE TIER ARCHITECTURE  

Design.aspx
<table align="center">
<tr>
<td><asp:Label ID="lblSearch" runat="server" Text="Search By Name"></asp:Label></td>
<td><asp:TextBox ID="txtSearch" runat="server"></asp:TextBox></td>
<td><asp:Button ID="btnSearch" runat="server" Text="Search" OnClick="btnSearch_Click" /></td>
</tr>
</table>
.cs(code behind)
protected void btnSearch_Click(object sender, EventArgs e)
{
BAL = new PersonBusinesslayer();
DataSet ds = BAL.Search(txtSearch.Text);
if (ds.Tables[0].Rows.Count == 0)
{
gvPerson.Visible = false;
lblMessage.Visible = true;
lblMessage.Text = "Sorry no records found";
}
else
{
lblMessage.Visible = false;
gvPerson.Visible = true;
gvPerson.DataSource = ds;
gvPerson.DataBind();
}
}
Businesslayer BAL=new Businesslayer();

protected void btnSearch_Click(object sender, EventArgs e)
{
BAL = new PersonBusinesslayer();
DataSet ds = BAL.Search(txtSearch.Text);
if (ds.Tables[0].Rows.Count == 0)
{
gvPerson.Visible = false;
lblMessage.Visible = true;
lblMessage.Text = "Sorry no records found";
}
else
{
lblMessage.Visible = false;
gvPerson.Visible = true;
gvPerson.DataSource = ds;
gvPerson.DataBind();
}
}

Business Layer
Datalayer DAL=new DataLayer();
public DataSet Search(string pName)
{
DAL = new PersonDatalayer();
return DAL.Search(pName);
}

Data layer
string Conn = ConfigurationManager.ConnectionStrings["MySampleDbConn"].ToString();
public DataSet Search(string pName)
{
cnn = new SqlConnection(Conn);
cmd = new SqlCommand("sp_SearchPersonInfo", cnn);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.AddWithValue("@pName", pName);
ada = new SqlDataAdapter(cmd);
ds = new DataSet();
ada.Fill(ds);
return ds;
}


Join Hands Change lives
Thanks & Regards
Straight Edge Society

Nuwan, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Nuwan on: 1/3/2012 [Member] Starter | Points: 25

Up
0
Down
Thanks Sir...
It is Great Help ....

Rathnayake

Nuwan, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response