In SQL:
create table test_State(STID int identity(1,1) ,SCode Varchar(3) primary key,SName varchar(20),Ccode varchar(3) foreign key references test_Country(Ccode))
create table test_City(CyID int identity(1,1),Cycode varchar(3) primary key,CyName varchar(20),SCode varchar(3) foreign key references test_State(SCode))
select * FROM test_Country
insert into test_Country values('IN','INDIA')
insert into test_Country values('US','USA')
SELECT * FROM test_State
insert into test_State values('TN','TamilNadu','IN')
insert into test_State values('KE','Kerala','IN')
insert into test_State values('WN','Washington','US')
insert into test_State values('TS','Texas','US')
select * from test_City
insert into test_City values('BY','Buckley','WN')
insert into test_City values('EA','Elma','WN')
insert into test_City values('NL','New London','TS')
insert into test_City values('VA','Victoria','TS')
Stored Procedure:
For Select:
CREATE procedure sp_Test_Select_ddl --'IN','TN','CH'
as
begin
select PID,PName,CountryCode,
(select CountryCode=
case CountryCode
when 'IN' then 'INDIA'
when 'US' then 'USA'
else 'No Country'
end) as CountryName,
StateCode,
(select StateCode=
case StateCode when 'KE' then 'KERALA'
when 'TN' then 'TamilNadu'
when 'TS' then 'TEXAS'
when 'WN' then 'WASHINGTON'
else 'No State'
end) as StateName,
CityCode,
(select CityCode=case CityCode when 'BY' then 'BUCKLEY'
when 'CH' then 'CHENNAI'
when 'CI' then 'COVAI'
when 'CN' then 'COCHIN'
when 'EA' then 'ELMA'
when 'MR' then 'MOONOR'
when 'MU' then 'MADURAI'
when 'NL' then 'NEW LONDON'
when 'TM' then 'TRIVANDRUM'
when 'VA' then 'VICTORIA'
else 'No City'
end) as CityName
from test_Person order by CountryName,StateName,CityName
end
For Insert & Update:
create procedure sp_Test_Insert
(
@perID int=null,
@perName varchar(30),
@CountryCode varchar(3),
@StateCode varchar(3),
@CityCode varchar(3)
)
as
begin
if exists(select * from test_Person where PID=@perID)
begin
update test_Person set PName=@perName,CountryCode=@CountryCode,StateCode=@StateCode,CityCode=@CityCode where PID=@perID
end
else
begin
insert into test_Person(PName,CountryCode,StateCode,CityCode) values(@perName,@CountryCode,@StateCode,@CityCode)
end
end
Default.aspx:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Test Page</title>
<script language="javascript" type="text/javascript">
function validateAll(getVal, SourceID) {
var ID = getVal.id;
var txt_NameID = ID.replace(SourceID, 'txt_Name');
var txt_NameVal = document.getElementById(txt_NameID).value;
if (txt_NameVal == "") {
alert('Please enter the Person Name');
document.getElementById(txt_NameID).focus();
return false;
}
var ddl_Ctry = ID.replace(SourceID, 'ddl_Country');
var ddl_CtryID = document.getElementById(ddl_Ctry);
var ddl_CtryVal = ddl_CtryID.options[ddl_CtryID.selectedIndex].value;
var ddl_State = ID.replace(SourceID, 'ddl_State');
var ddl_StateID = document.getElementById(ddl_State);
var ddl_StateVal = ddl_StateID.options[ddl_StateID.selectedIndex].value;
var ddl_City = ID.replace(SourceID, 'ddl_City');
var ddl_CityID = document.getElementById(ddl_City);
var ddl_CityVal = ddl_CityID.options[ddl_CityID.selectedIndex].value;
if (ddl_CtryVal == 0) {
alert('Please select Country');
document.getElementById(ddl_Ctry).focus();
return false;
}
else if (ddl_StateVal == 0) {
alert('Please select State');
document.getElementById(ddl_State).focus();
return false;
}
else if (ddl_CityVal == 0) {
alert('Please select City');
document.getElementById(ddl_City).focus();
return false;
}
}
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<table border="0" cellpadding="0" cellspacing="0" width="1258px" align="center">
<tr>
<td>
</td>
</tr>
<tr>
<td>
<table border="0" cellpadding="0" cellspacing="0" width="60%" align="center">
<tr>
<td>
Test Page
</td>
</tr>
<tr>
<td>
<asp:GridView ID="GridView1" runat="server" Width="100%" ShowFooter="True" AutoGenerateColumns="False"
GridLines="None" onpageindexchanging="GridView1_PageIndexChanging" DataKeyNames="PID"
onsorting="GridView1_Sorting" onrowcommand="GridView1_RowCommand"
onrowdatabound="GridView1_RowDataBound" onrowdeleting="GridView1_RowDeleting"
onrowediting="GridView1_RowEditing" onrowupdating="GridView1_RowUpdating"
PageSize="5" AllowPaging="true" AllowSorting="true"
onrowcancelingedit="GridView1_RowCancelingEdit">
<Columns>
<asp:TemplateField HeaderText="Person Name" SortExpression="PName">
<EditItemTemplate>
<asp:TextBox ID="txt_Name" runat="server" MaxLength="30" Text='<%# Bind("PName") %>'></asp:TextBox>
</EditItemTemplate>
<FooterTemplate>
<asp:TextBox ID="txt_Name" runat="server" MaxLength="30" Visible="false"></asp:TextBox>
</FooterTemplate>
<ItemTemplate>
<asp:Label ID="lbl_Name" runat="server" Text='<%# Bind("PName") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="CountryName" SortExpression="CName">
<EditItemTemplate>
<asp:DropDownList ID="ddl_Country" runat="server">
</asp:DropDownList>
</EditItemTemplate>
<FooterTemplate>
<asp:DropDownList ID="ddl_Country" runat="server" AutoPostBack="true" Visible="false" OnSelectedIndexChanged="ddl_Country_SelectedIndexChanged">
</asp:DropDownList>
</FooterTemplate>
<ItemTemplate>
<asp:Label ID="lbl_Country" runat="server" Text='<%# Bind("CountryName") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="State Name" SortExpression="SName">
<EditItemTemplate>
<asp:DropDownList ID="ddl_State" runat="server">
</asp:DropDownList>
</EditItemTemplate>
<FooterTemplate>
<asp:DropDownList ID="ddl_State" runat="server" AutoPostBack="true" Visible="false" OnSelectedIndexChanged="ddl_State_SelectedIndexChanged">
</asp:DropDownList>
</FooterTemplate>
<ItemTemplate>
<asp:Label ID="lbl_State" runat="server" Text='<%# Bind("StateName") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="City Name" SortExpression="CyName">
<EditItemTemplate>
<asp:DropDownList ID="ddl_City" runat="server" >
</asp:DropDownList>
</EditItemTemplate>
<FooterTemplate>
<asp:DropDownList ID="ddl_City" runat="server" AutoPostBack="true" Visible="false" OnSelectedIndexChanged="ddl_City_SelectedIndexChanged">
</asp:DropDownList>
</FooterTemplate>
<ItemTemplate>
<asp:Label ID="lbl_City" runat="server" Text='<%# Bind("CityName") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField>
<EditItemTemplate>
<asp:LinkButton ID="lnk_Update" runat="server" CommandName="Update" OnClientClick="return validateAll(this,'lnk_Update');">Update</asp:LinkButton>
<asp:LinkButton ID="lnk_Cancel" runat="server" CommandName="Cancel">Cancel</asp:LinkButton>
</EditItemTemplate>
<FooterTemplate>
<asp:LinkButton ID="lnk_AddNew" runat="server" CommandName="AddNew">AddNew</asp:LinkButton>
<asp:LinkButton ID="lnk_Save" runat="server" Visible="false" CommandName="Save" OnClientClick="return validateAll(this,'lnk_Save');">Save</asp:LinkButton>
<asp:LinkButton ID="lnk_Cancel" runat="server" Visible="false" CommandName="Cancel">Cancel</asp:LinkButton>
</FooterTemplate>
<ItemTemplate>
<asp:LinkButton ID="lnk_Edit" runat="server" CommandName="Edit">Edit</asp:LinkButton>
<asp:LinkButton ID="lnk_Delete" runat="server" CommandName="Delete">Delete</asp:LinkButton>
</ItemTemplate>
</asp:TemplateField>
</Columns>
<PagerStyle HorizontalAlign="Center" />
<HeaderStyle HorizontalAlign="Left" />
<RowStyle HorizontalAlign="Left" />
</asp:GridView>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td>
</td>
</tr>
</table>
</div>
</form>
</body>
</html>
Default.aspx.cs:
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 Test_EL;
using Test_BAL;
using Test_DAL;
namespace WebApplication1
{
public partial class _Default : System.Web.UI.Page
{
EntityTier eTier = new EntityTier();
BusinessTier bTier = new BusinessTier();
DataTable dt = new DataTable();
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
FillGrid();
}
}
private void FillGrid()
{
dt = (DataTable)bTier.GetGrid();
if (dt != null)
{
DataView dv = new DataView();
dv = dt.DefaultView;
if (!String.IsNullOrEmpty(Convert.ToString(ViewState["SortDirection"])) && !String.IsNullOrEmpty(Convert.ToString(ViewState["SortExpression"])))
{
dv.Sort = string.Format("{0} {1}", Convert.ToString(ViewState["SortExpression"]), Convert.ToString(ViewState["SortDirection"]));
}
GridView1.DataSource = dt;
GridView1.DataBind();
}
}
protected void GridView1_Sorting(object sender, GridViewSortEventArgs e)
{
ViewState["SortExpression"] = e.SortExpression;
if (Convert.ToString(ViewState["SortDirection"]).Equals("ASC"))
{
ViewState["SortDirection"] = "DESC";
}
else
{
ViewState["SortDirection"] = "ASC";
}
}
protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
{
GridView1.PageIndex = e.NewPageIndex;
FillGrid();
}
protected void GridView1_RowEditing(object sender, GridViewEditEventArgs e)
{
GridView1.EditIndex = e.NewEditIndex;
FillGrid();
((TextBox)GridView1.Rows[e.NewEditIndex].FindControl("txt_Name")).Focus();
}
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
DropDownList ddl_Country = (DropDownList)e.Row.FindControl("ddl_Country");
DropDownList ddl_State = (DropDownList)e.Row.FindControl("ddl_State");
DropDownList ddl_City = (DropDownList)e.Row.FindControl("ddl_City");
if (e.Row.RowType == DataControlRowType.Footer)
{
TextBox txt_Name = (TextBox)e.Row.FindControl("txt_Name");
txt_Name.Focus();
ddl_Country.Items.Insert(0, new ListItem("--Select--", "0"));
ddl_State.Items.Insert(0, new ListItem("--Select--", "0"));
ddl_City.Items.Insert(0, new ListItem("--Select--", "0"));
FillCountry(e);
}
if ((e.Row.RowState & DataControlRowState.Edit) > 0)
{
//GridViewRow gvr = GridView1.Rows[e.Row.RowIndex];
int id = Convert.ToInt32(GridView1.DataKeys[e.Row.RowIndex].Values[0].ToString());
TextBox txt_Name = (TextBox)e.Row.FindControl("txt_Name");
txt_Name.Focus();
DataTable dtCountry = new DataTable();
dtCountry = (DataTable)bTier.GetCountry();
if (dtCountry != null && dtCountry.Rows.Count > 0)
{
ddl_Country.DataSource = dtCountry;
ddl_Country.DataTextField = "CName";
ddl_Country.DataValueField = "Ccode";
ddl_Country.DataBind();
ddl_Country.Items.Insert(0, new ListItem("--Select--", "0"));
DataRowView drv = e.Row.DataItem as DataRowView;
ddl_Country.SelectedValue = drv["CountryCode"].ToString();
eTier.CountryCode = drv["CountryCode"].ToString(); ;
}
DataTable dtState = new DataTable();
dtState = (DataTable)bTier.GetState(eTier);
if (dtState != null & dtState.Rows.Count > 0)
{
ddl_State.DataSource = dtState;
ddl_State.DataTextField = "SName";
ddl_State.DataValueField = "SCode";
ddl_State.DataBind();
ddl_State.Items.Insert(0, new ListItem("--Select--", "0"));
DataRowView drv = e.Row.DataItem as DataRowView;
ddl_State.SelectedValue = drv["StateCode"].ToString();
eTier.StateCode = ddl_State.SelectedValue;
}
DataTable dtCity = new DataTable();
//eTier.StateCode = ddl_State.SelectedValue;
dtCity = (DataTable)bTier.GetCity(eTier);
if (dtCity != null & dtCity.Rows.Count > 0)
{
ddl_City.DataSource = dtCity;
ddl_City.DataTextField = "CyName";
ddl_City.DataValueField = "CyCode";
ddl_City.DataBind();
ddl_City.Items.Insert(0, new ListItem("--Select--", "0"));
DataRowView drv = e.Row.DataItem as DataRowView;
ddl_City.SelectedValue = drv["CityCode"].ToString();
}
}
}
private void FillCountry(GridViewRowEventArgs e)
{
DropDownList ddl_Country = (DropDownList)e.Row.FindControl("ddl_Country");
DataTable dtCountry = new DataTable();
dtCountry = (DataTable)bTier.GetCountry();
if (dtCountry != null && dtCountry.Rows.Count > 0)
{
ddl_Country.DataSource = dtCountry;
ddl_Country.DataTextField = "CName";
ddl_Country.DataValueField = "Ccode";
ddl_Country.DataBind();
ddl_Country.Items.Insert(0, new ListItem("--Select--", "0"));
}
}
protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e)
{
GridViewRow gvr = GridView1.Rows[e.RowIndex];
InsertUpdateOpertions(gvr, "Update");
GridView1.EditIndex = -1;
FillGrid();
}
protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e)
{
eTier.PID = Convert.ToInt32(GridView1.DataKeys[e.RowIndex].Values[0].ToString());
Boolean val = bTier.DelValues(eTier);
if (val == true)
{
ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "Alert", "alert('Deleted Successfully');", true);
}
else
{
ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "Alert", "alert('Deleted Not Successfully');", true);
}
FillGrid();
}
protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
{
if (e.CommandName.Equals("AddNew"))
{
GridViewRow gvr = (GridViewRow)((LinkButton)e.CommandSource).NamingContainer;
FieldsVisibilty(gvr, true);
TextBox txt_Name = (TextBox)gvr.FindControl("txt_Name");
txt_Name.Focus();
}
if (e.CommandName.Equals("Save"))
{
GridViewRow gvr = (GridViewRow)((LinkButton)e.CommandSource).NamingContainer;
InsertUpdateOpertions(gvr, e.CommandName);
FillGrid();
}
}
private void InsertUpdateOpertions(GridViewRow gvr, string CommandName)
{
if (CommandName.Equals("Save"))
{
// eTier.PID =null;
eTier.PName = ((TextBox)gvr.FindControl("txt_Name")).Text;
eTier.CountryCode = ((DropDownList)gvr.FindControl("ddl_Country")).SelectedValue;
eTier.StateCode = ((DropDownList)gvr.FindControl("ddl_State")).SelectedValue;
eTier.CityCode = ((DropDownList)gvr.FindControl("ddl_City")).SelectedValue;
Boolean val = bTier.InsUpdtValues(eTier);
if (val == true)
{
ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "Alert", "alert('Saved Successfully');", true);
}
else
{
ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "Alert", "alert('Saved Not Successfully');", true);
}
}
else
{
eTier.PID = (int)GridView1.DataKeys[gvr.RowIndex].Values[0];
eTier.PName = ((TextBox)gvr.FindControl("txt_Name")).Text;
eTier.CountryCode = ((DropDownList)gvr.FindControl("ddl_Country")).SelectedValue;
eTier.StateCode = ((DropDownList)gvr.FindControl("ddl_State")).SelectedValue;
eTier.CityCode = ((DropDownList)gvr.FindControl("ddl_City")).SelectedValue;
Boolean val = bTier.InsUpdtValues(eTier);
if (val == true)
{
ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "Alert", "alert('Updation Successfully');", true);
}
else
{
ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "Alert", "alert('Updation Not Successfully');", true);
}
}
}
private void FieldsVisibilty(GridViewRow gvr, Boolean getBoolVal)
{
((TextBox)gvr.FindControl("txt_Name")).Visible = getBoolVal;
((DropDownList)gvr.FindControl("ddl_Country")).Visible = getBoolVal;
((DropDownList)gvr.FindControl("ddl_State")).Visible = getBoolVal;
((DropDownList)gvr.FindControl("ddl_City")).Visible = getBoolVal;
((LinkButton)gvr.FindControl("lnk_Save")).Visible = getBoolVal;
((LinkButton)gvr.FindControl("lnk_Cancel")).Visible = getBoolVal;
if (getBoolVal == true)
{
((LinkButton)gvr.FindControl("lnk_AddNew")).Visible = false;
}
else
{
((LinkButton)gvr.FindControl("lnk_AddNew")).Visible = true;
}
}
protected void ddl_Country_SelectedIndexChanged(object sender, EventArgs e)
{
DropDownList ddl_Country = (DropDownList)GridView1.FooterRow.FindControl("ddl_Country");
FillState(ddl_Country.SelectedValue, e);
}
private void FillState(string CountryCode, EventArgs e)
{
DropDownList ddl_State = (DropDownList)GridView1.FooterRow.FindControl("ddl_State");
eTier.CountryCode = CountryCode;
ddl_State.DataSource = (DataTable)bTier.GetState(eTier);
ddl_State.DataTextField = "SName";
ddl_State.DataValueField = "SCode";
ddl_State.DataBind();
ddl_State.Items.Insert(0, new ListItem("--Select--", "0"));
}
protected void ddl_State_SelectedIndexChanged(object sender, EventArgs e)
{
DropDownList ddl_State = (DropDownList)GridView1.FooterRow.FindControl("ddl_State");
FillCity(ddl_State.SelectedValue, e);
}
private void FillCity(string StateCode, EventArgs e)
{
DropDownList ddl_City = (DropDownList)GridView1.FooterRow.FindControl("ddl_City");
eTier.StateCode = StateCode;
ddl_City.DataSource = (DataTable)bTier.GetCity(eTier);
ddl_City.DataTextField = "CyName";
ddl_City.DataValueField = "CyCode";
ddl_City.DataBind();
ddl_City.Items.Insert(0, new ListItem("--Select--", "0"));
}
protected void ddl_City_SelectedIndexChanged(object sender, EventArgs e)
{
}
protected void GridView1_RowCancelingEdit(object sender, GridViewCancelEditEventArgs e)
{
GridView1.EditIndex = -1;
FillGrid();
}
}
}
Test_EL.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Test_EL
{
public class EntityTier
{
public int PID { get; set; }
public string PName { get; set; }
public int CountryID { get; set; }
public string CounryName { get; set; }
public string CountryCode { get; set; }
public int StateID { get; set; }
public string StateName { get; set; }
public string StateCode { get; set; }
public int CityID { get; set; }
public string CityName { get; set; }
public string CityCode { get; set; }
}
}
Test_BAL.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Test_DAL;
using Test_EL;
namespace Test_BAL
{
public class BusinessTier
{
DataTier dTier = new DataTier();
public object GetGrid()
{
return dTier.GetGrid();
}
public object GetCountry()
{
return dTier.GetCountry();
}
public object GetState(EntityTier eTier)
{
return dTier.GetState(eTier);
}
public object GetCity(EntityTier eTier)
{
return dTier.GetCity(eTier);
}
public Boolean InsUpdtValues(EntityTier eTier)
{
return dTier.InsertUpdateValues(eTier);
}
public Boolean DelValues(EntityTier eTier)
{
return dTier.DeleteValues(eTier);
}
}
}
Test_DAL.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Configuration;
using System.Data;
using System.Data.SqlClient;
using Test_EL;
namespace Test_DAL
{
public class DataTier
{
string conStr = ConfigurationManager.ConnectionStrings["testCon"].ConnectionString;
SqlConnection con;
SqlCommand cmd;
SqlDataAdapter sqlda;
DataTable dt;
DataSet ds;
public object GetGrid()
{
using (con = new SqlConnection(conStr))
{
con.Open();
string selQry = "sp_Test_Select_ddl";
using (cmd = new SqlCommand(selQry, con))
{
sqlda = new SqlDataAdapter(cmd);
dt = new DataTable();
sqlda.Fill(dt);
}
}
return dt;
}
public object GetCountry()
{
using (con = new SqlConnection(conStr))
{
con.Open();
string selCtry = string.Format("select * from test_country");
using (cmd = new SqlCommand(selCtry, con))
{
sqlda = new SqlDataAdapter(cmd);
dt = new DataTable();
sqlda.Fill(dt);
}
}
return dt;
}
public object GetState(EntityTier eTier)
{
using (con = new SqlConnection(conStr))
{
con.Open();
string selState = string.Format("select * from test_state where Ccode='{0}'", eTier.CountryCode);
using (cmd = new SqlCommand(selState, con))
{
sqlda = new SqlDataAdapter(cmd);
dt = new DataTable();
sqlda.Fill(dt);
}
}
return dt;
}
public object GetCity(EntityTier eTier)
{
using (con = new SqlConnection(conStr))
{
con.Open();
string selCity = string.Format("select * from test_city where SCode='{0}'", eTier.StateCode);
using (cmd = new SqlCommand(selCity, con))
{
sqlda = new SqlDataAdapter(cmd);
dt = new DataTable();
sqlda.Fill(dt);
}
}
return dt;
}
public Boolean InsertUpdateValues(EntityTier eTier)
{
using (con = new SqlConnection(conStr))
{
con.Open();
string insQry = "sp_Test_Insert";
using (cmd = new SqlCommand(insQry, con))
{
cmd.CommandType = CommandType.StoredProcedure;
if (eTier.PID > 0)
{
cmd.Parameters.AddWithValue("@perID", eTier.PID);
}
else
{
cmd.Parameters.AddWithValue("@perID", eTier.PID);
}
cmd.Parameters.AddWithValue("@perName", eTier.PName);
cmd.Parameters.AddWithValue("@CountryCode", eTier.CountryCode);
cmd.Parameters.AddWithValue("@StateCode", eTier.StateCode);
cmd.Parameters.AddWithValue("@CityCode", eTier.CityCode);
cmd.ExecuteNonQuery();
}
}
return true;
}
public Boolean DeleteValues(EntityTier eTier)
{
using (con = new SqlConnection(conStr))
{
con.Open();
string delQry = string.Format("delete from test_Person where PID={0}", eTier.PID);
using (cmd = new SqlCommand(delQry, con))
{
cmd.ExecuteNonQuery();
}
}
return true;
}
}
}
Web.config:
<connectionStrings>
<add name="testCon" connectionString="data source=test-PC;user id=PC;password=testPC;Initial Catalog=test;Persist Security Info=True;" providerName="System.Data.SqlClient"/>
</connectionStrings>
create table test_State(STID int identity(1,1) ,SCode Varchar(3) primary key,SName varchar(20),Ccode varchar(3) foreign key references test_Country(Ccode))
create table test_City(CyID int identity(1,1),Cycode varchar(3) primary key,CyName varchar(20),SCode varchar(3) foreign key references test_State(SCode))
select * FROM test_Country
insert into test_Country values('IN','INDIA')
insert into test_Country values('US','USA')
SELECT * FROM test_State
insert into test_State values('TN','TamilNadu','IN')
insert into test_State values('KE','Kerala','IN')
insert into test_State values('WN','Washington','US')
insert into test_State values('TS','Texas','US')
select * from test_City
insert into test_City values('BY','Buckley','WN')
insert into test_City values('EA','Elma','WN')
insert into test_City values('NL','New London','TS')
insert into test_City values('VA','Victoria','TS')
Stored Procedure:
For Select:
CREATE procedure sp_Test_Select_ddl --'IN','TN','CH'
as
begin
select PID,PName,CountryCode,
(select CountryCode=
case CountryCode
when 'IN' then 'INDIA'
when 'US' then 'USA'
else 'No Country'
end) as CountryName,
StateCode,
(select StateCode=
case StateCode when 'KE' then 'KERALA'
when 'TN' then 'TamilNadu'
when 'TS' then 'TEXAS'
when 'WN' then 'WASHINGTON'
else 'No State'
end) as StateName,
CityCode,
(select CityCode=case CityCode when 'BY' then 'BUCKLEY'
when 'CH' then 'CHENNAI'
when 'CI' then 'COVAI'
when 'CN' then 'COCHIN'
when 'EA' then 'ELMA'
when 'MR' then 'MOONOR'
when 'MU' then 'MADURAI'
when 'NL' then 'NEW LONDON'
when 'TM' then 'TRIVANDRUM'
when 'VA' then 'VICTORIA'
else 'No City'
end) as CityName
from test_Person order by CountryName,StateName,CityName
end
For Insert & Update:
create procedure sp_Test_Insert
(
@perID int=null,
@perName varchar(30),
@CountryCode varchar(3),
@StateCode varchar(3),
@CityCode varchar(3)
)
as
begin
if exists(select * from test_Person where PID=@perID)
begin
update test_Person set PName=@perName,CountryCode=@CountryCode,StateCode=@StateCode,CityCode=@CityCode where PID=@perID
end
else
begin
insert into test_Person(PName,CountryCode,StateCode,CityCode) values(@perName,@CountryCode,@StateCode,@CityCode)
end
end
Default.aspx:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Test Page</title>
<script language="javascript" type="text/javascript">
function validateAll(getVal, SourceID) {
var ID = getVal.id;
var txt_NameID = ID.replace(SourceID, 'txt_Name');
var txt_NameVal = document.getElementById(txt_NameID).value;
if (txt_NameVal == "") {
alert('Please enter the Person Name');
document.getElementById(txt_NameID).focus();
return false;
}
var ddl_Ctry = ID.replace(SourceID, 'ddl_Country');
var ddl_CtryID = document.getElementById(ddl_Ctry);
var ddl_CtryVal = ddl_CtryID.options[ddl_CtryID.selectedIndex].value;
var ddl_State = ID.replace(SourceID, 'ddl_State');
var ddl_StateID = document.getElementById(ddl_State);
var ddl_StateVal = ddl_StateID.options[ddl_StateID.selectedIndex].value;
var ddl_City = ID.replace(SourceID, 'ddl_City');
var ddl_CityID = document.getElementById(ddl_City);
var ddl_CityVal = ddl_CityID.options[ddl_CityID.selectedIndex].value;
if (ddl_CtryVal == 0) {
alert('Please select Country');
document.getElementById(ddl_Ctry).focus();
return false;
}
else if (ddl_StateVal == 0) {
alert('Please select State');
document.getElementById(ddl_State).focus();
return false;
}
else if (ddl_CityVal == 0) {
alert('Please select City');
document.getElementById(ddl_City).focus();
return false;
}
}
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<table border="0" cellpadding="0" cellspacing="0" width="1258px" align="center">
<tr>
<td>
</td>
</tr>
<tr>
<td>
<table border="0" cellpadding="0" cellspacing="0" width="60%" align="center">
<tr>
<td>
Test Page
</td>
</tr>
<tr>
<td>
<asp:GridView ID="GridView1" runat="server" Width="100%" ShowFooter="True" AutoGenerateColumns="False"
GridLines="None" onpageindexchanging="GridView1_PageIndexChanging" DataKeyNames="PID"
onsorting="GridView1_Sorting" onrowcommand="GridView1_RowCommand"
onrowdatabound="GridView1_RowDataBound" onrowdeleting="GridView1_RowDeleting"
onrowediting="GridView1_RowEditing" onrowupdating="GridView1_RowUpdating"
PageSize="5" AllowPaging="true" AllowSorting="true"
onrowcancelingedit="GridView1_RowCancelingEdit">
<Columns>
<asp:TemplateField HeaderText="Person Name" SortExpression="PName">
<EditItemTemplate>
<asp:TextBox ID="txt_Name" runat="server" MaxLength="30" Text='<%# Bind("PName") %>'></asp:TextBox>
</EditItemTemplate>
<FooterTemplate>
<asp:TextBox ID="txt_Name" runat="server" MaxLength="30" Visible="false"></asp:TextBox>
</FooterTemplate>
<ItemTemplate>
<asp:Label ID="lbl_Name" runat="server" Text='<%# Bind("PName") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="CountryName" SortExpression="CName">
<EditItemTemplate>
<asp:DropDownList ID="ddl_Country" runat="server">
</asp:DropDownList>
</EditItemTemplate>
<FooterTemplate>
<asp:DropDownList ID="ddl_Country" runat="server" AutoPostBack="true" Visible="false" OnSelectedIndexChanged="ddl_Country_SelectedIndexChanged">
</asp:DropDownList>
</FooterTemplate>
<ItemTemplate>
<asp:Label ID="lbl_Country" runat="server" Text='<%# Bind("CountryName") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="State Name" SortExpression="SName">
<EditItemTemplate>
<asp:DropDownList ID="ddl_State" runat="server">
</asp:DropDownList>
</EditItemTemplate>
<FooterTemplate>
<asp:DropDownList ID="ddl_State" runat="server" AutoPostBack="true" Visible="false" OnSelectedIndexChanged="ddl_State_SelectedIndexChanged">
</asp:DropDownList>
</FooterTemplate>
<ItemTemplate>
<asp:Label ID="lbl_State" runat="server" Text='<%# Bind("StateName") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="City Name" SortExpression="CyName">
<EditItemTemplate>
<asp:DropDownList ID="ddl_City" runat="server" >
</asp:DropDownList>
</EditItemTemplate>
<FooterTemplate>
<asp:DropDownList ID="ddl_City" runat="server" AutoPostBack="true" Visible="false" OnSelectedIndexChanged="ddl_City_SelectedIndexChanged">
</asp:DropDownList>
</FooterTemplate>
<ItemTemplate>
<asp:Label ID="lbl_City" runat="server" Text='<%# Bind("CityName") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField>
<EditItemTemplate>
<asp:LinkButton ID="lnk_Update" runat="server" CommandName="Update" OnClientClick="return validateAll(this,'lnk_Update');">Update</asp:LinkButton>
<asp:LinkButton ID="lnk_Cancel" runat="server" CommandName="Cancel">Cancel</asp:LinkButton>
</EditItemTemplate>
<FooterTemplate>
<asp:LinkButton ID="lnk_AddNew" runat="server" CommandName="AddNew">AddNew</asp:LinkButton>
<asp:LinkButton ID="lnk_Save" runat="server" Visible="false" CommandName="Save" OnClientClick="return validateAll(this,'lnk_Save');">Save</asp:LinkButton>
<asp:LinkButton ID="lnk_Cancel" runat="server" Visible="false" CommandName="Cancel">Cancel</asp:LinkButton>
</FooterTemplate>
<ItemTemplate>
<asp:LinkButton ID="lnk_Edit" runat="server" CommandName="Edit">Edit</asp:LinkButton>
<asp:LinkButton ID="lnk_Delete" runat="server" CommandName="Delete">Delete</asp:LinkButton>
</ItemTemplate>
</asp:TemplateField>
</Columns>
<PagerStyle HorizontalAlign="Center" />
<HeaderStyle HorizontalAlign="Left" />
<RowStyle HorizontalAlign="Left" />
</asp:GridView>
</td>
</tr>
</table>
</td>
</tr>
<tr>
<td>
</td>
</tr>
</table>
</div>
</form>
</body>
</html>
Default.aspx.cs:
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 Test_EL;
using Test_BAL;
using Test_DAL;
namespace WebApplication1
{
public partial class _Default : System.Web.UI.Page
{
EntityTier eTier = new EntityTier();
BusinessTier bTier = new BusinessTier();
DataTable dt = new DataTable();
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
FillGrid();
}
}
private void FillGrid()
{
dt = (DataTable)bTier.GetGrid();
if (dt != null)
{
DataView dv = new DataView();
dv = dt.DefaultView;
if (!String.IsNullOrEmpty(Convert.ToString(ViewState["SortDirection"])) && !String.IsNullOrEmpty(Convert.ToString(ViewState["SortExpression"])))
{
dv.Sort = string.Format("{0} {1}", Convert.ToString(ViewState["SortExpression"]), Convert.ToString(ViewState["SortDirection"]));
}
GridView1.DataSource = dt;
GridView1.DataBind();
}
}
protected void GridView1_Sorting(object sender, GridViewSortEventArgs e)
{
ViewState["SortExpression"] = e.SortExpression;
if (Convert.ToString(ViewState["SortDirection"]).Equals("ASC"))
{
ViewState["SortDirection"] = "DESC";
}
else
{
ViewState["SortDirection"] = "ASC";
}
}
protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)
{
GridView1.PageIndex = e.NewPageIndex;
FillGrid();
}
protected void GridView1_RowEditing(object sender, GridViewEditEventArgs e)
{
GridView1.EditIndex = e.NewEditIndex;
FillGrid();
((TextBox)GridView1.Rows[e.NewEditIndex].FindControl("txt_Name")).Focus();
}
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
DropDownList ddl_Country = (DropDownList)e.Row.FindControl("ddl_Country");
DropDownList ddl_State = (DropDownList)e.Row.FindControl("ddl_State");
DropDownList ddl_City = (DropDownList)e.Row.FindControl("ddl_City");
if (e.Row.RowType == DataControlRowType.Footer)
{
TextBox txt_Name = (TextBox)e.Row.FindControl("txt_Name");
txt_Name.Focus();
ddl_Country.Items.Insert(0, new ListItem("--Select--", "0"));
ddl_State.Items.Insert(0, new ListItem("--Select--", "0"));
ddl_City.Items.Insert(0, new ListItem("--Select--", "0"));
FillCountry(e);
}
if ((e.Row.RowState & DataControlRowState.Edit) > 0)
{
//GridViewRow gvr = GridView1.Rows[e.Row.RowIndex];
int id = Convert.ToInt32(GridView1.DataKeys[e.Row.RowIndex].Values[0].ToString());
TextBox txt_Name = (TextBox)e.Row.FindControl("txt_Name");
txt_Name.Focus();
DataTable dtCountry = new DataTable();
dtCountry = (DataTable)bTier.GetCountry();
if (dtCountry != null && dtCountry.Rows.Count > 0)
{
ddl_Country.DataSource = dtCountry;
ddl_Country.DataTextField = "CName";
ddl_Country.DataValueField = "Ccode";
ddl_Country.DataBind();
ddl_Country.Items.Insert(0, new ListItem("--Select--", "0"));
DataRowView drv = e.Row.DataItem as DataRowView;
ddl_Country.SelectedValue = drv["CountryCode"].ToString();
eTier.CountryCode = drv["CountryCode"].ToString(); ;
}
DataTable dtState = new DataTable();
dtState = (DataTable)bTier.GetState(eTier);
if (dtState != null & dtState.Rows.Count > 0)
{
ddl_State.DataSource = dtState;
ddl_State.DataTextField = "SName";
ddl_State.DataValueField = "SCode";
ddl_State.DataBind();
ddl_State.Items.Insert(0, new ListItem("--Select--", "0"));
DataRowView drv = e.Row.DataItem as DataRowView;
ddl_State.SelectedValue = drv["StateCode"].ToString();
eTier.StateCode = ddl_State.SelectedValue;
}
DataTable dtCity = new DataTable();
//eTier.StateCode = ddl_State.SelectedValue;
dtCity = (DataTable)bTier.GetCity(eTier);
if (dtCity != null & dtCity.Rows.Count > 0)
{
ddl_City.DataSource = dtCity;
ddl_City.DataTextField = "CyName";
ddl_City.DataValueField = "CyCode";
ddl_City.DataBind();
ddl_City.Items.Insert(0, new ListItem("--Select--", "0"));
DataRowView drv = e.Row.DataItem as DataRowView;
ddl_City.SelectedValue = drv["CityCode"].ToString();
}
}
}
private void FillCountry(GridViewRowEventArgs e)
{
DropDownList ddl_Country = (DropDownList)e.Row.FindControl("ddl_Country");
DataTable dtCountry = new DataTable();
dtCountry = (DataTable)bTier.GetCountry();
if (dtCountry != null && dtCountry.Rows.Count > 0)
{
ddl_Country.DataSource = dtCountry;
ddl_Country.DataTextField = "CName";
ddl_Country.DataValueField = "Ccode";
ddl_Country.DataBind();
ddl_Country.Items.Insert(0, new ListItem("--Select--", "0"));
}
}
protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e)
{
GridViewRow gvr = GridView1.Rows[e.RowIndex];
InsertUpdateOpertions(gvr, "Update");
GridView1.EditIndex = -1;
FillGrid();
}
protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e)
{
eTier.PID = Convert.ToInt32(GridView1.DataKeys[e.RowIndex].Values[0].ToString());
Boolean val = bTier.DelValues(eTier);
if (val == true)
{
ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "Alert", "alert('Deleted Successfully');", true);
}
else
{
ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "Alert", "alert('Deleted Not Successfully');", true);
}
FillGrid();
}
protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
{
if (e.CommandName.Equals("AddNew"))
{
GridViewRow gvr = (GridViewRow)((LinkButton)e.CommandSource).NamingContainer;
FieldsVisibilty(gvr, true);
TextBox txt_Name = (TextBox)gvr.FindControl("txt_Name");
txt_Name.Focus();
}
if (e.CommandName.Equals("Save"))
{
GridViewRow gvr = (GridViewRow)((LinkButton)e.CommandSource).NamingContainer;
InsertUpdateOpertions(gvr, e.CommandName);
FillGrid();
}
}
private void InsertUpdateOpertions(GridViewRow gvr, string CommandName)
{
if (CommandName.Equals("Save"))
{
// eTier.PID =null;
eTier.PName = ((TextBox)gvr.FindControl("txt_Name")).Text;
eTier.CountryCode = ((DropDownList)gvr.FindControl("ddl_Country")).SelectedValue;
eTier.StateCode = ((DropDownList)gvr.FindControl("ddl_State")).SelectedValue;
eTier.CityCode = ((DropDownList)gvr.FindControl("ddl_City")).SelectedValue;
Boolean val = bTier.InsUpdtValues(eTier);
if (val == true)
{
ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "Alert", "alert('Saved Successfully');", true);
}
else
{
ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "Alert", "alert('Saved Not Successfully');", true);
}
}
else
{
eTier.PID = (int)GridView1.DataKeys[gvr.RowIndex].Values[0];
eTier.PName = ((TextBox)gvr.FindControl("txt_Name")).Text;
eTier.CountryCode = ((DropDownList)gvr.FindControl("ddl_Country")).SelectedValue;
eTier.StateCode = ((DropDownList)gvr.FindControl("ddl_State")).SelectedValue;
eTier.CityCode = ((DropDownList)gvr.FindControl("ddl_City")).SelectedValue;
Boolean val = bTier.InsUpdtValues(eTier);
if (val == true)
{
ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "Alert", "alert('Updation Successfully');", true);
}
else
{
ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "Alert", "alert('Updation Not Successfully');", true);
}
}
}
private void FieldsVisibilty(GridViewRow gvr, Boolean getBoolVal)
{
((TextBox)gvr.FindControl("txt_Name")).Visible = getBoolVal;
((DropDownList)gvr.FindControl("ddl_Country")).Visible = getBoolVal;
((DropDownList)gvr.FindControl("ddl_State")).Visible = getBoolVal;
((DropDownList)gvr.FindControl("ddl_City")).Visible = getBoolVal;
((LinkButton)gvr.FindControl("lnk_Save")).Visible = getBoolVal;
((LinkButton)gvr.FindControl("lnk_Cancel")).Visible = getBoolVal;
if (getBoolVal == true)
{
((LinkButton)gvr.FindControl("lnk_AddNew")).Visible = false;
}
else
{
((LinkButton)gvr.FindControl("lnk_AddNew")).Visible = true;
}
}
protected void ddl_Country_SelectedIndexChanged(object sender, EventArgs e)
{
DropDownList ddl_Country = (DropDownList)GridView1.FooterRow.FindControl("ddl_Country");
FillState(ddl_Country.SelectedValue, e);
}
private void FillState(string CountryCode, EventArgs e)
{
DropDownList ddl_State = (DropDownList)GridView1.FooterRow.FindControl("ddl_State");
eTier.CountryCode = CountryCode;
ddl_State.DataSource = (DataTable)bTier.GetState(eTier);
ddl_State.DataTextField = "SName";
ddl_State.DataValueField = "SCode";
ddl_State.DataBind();
ddl_State.Items.Insert(0, new ListItem("--Select--", "0"));
}
protected void ddl_State_SelectedIndexChanged(object sender, EventArgs e)
{
DropDownList ddl_State = (DropDownList)GridView1.FooterRow.FindControl("ddl_State");
FillCity(ddl_State.SelectedValue, e);
}
private void FillCity(string StateCode, EventArgs e)
{
DropDownList ddl_City = (DropDownList)GridView1.FooterRow.FindControl("ddl_City");
eTier.StateCode = StateCode;
ddl_City.DataSource = (DataTable)bTier.GetCity(eTier);
ddl_City.DataTextField = "CyName";
ddl_City.DataValueField = "CyCode";
ddl_City.DataBind();
ddl_City.Items.Insert(0, new ListItem("--Select--", "0"));
}
protected void ddl_City_SelectedIndexChanged(object sender, EventArgs e)
{
}
protected void GridView1_RowCancelingEdit(object sender, GridViewCancelEditEventArgs e)
{
GridView1.EditIndex = -1;
FillGrid();
}
}
}
Test_EL.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Test_EL
{
public class EntityTier
{
public int PID { get; set; }
public string PName { get; set; }
public int CountryID { get; set; }
public string CounryName { get; set; }
public string CountryCode { get; set; }
public int StateID { get; set; }
public string StateName { get; set; }
public string StateCode { get; set; }
public int CityID { get; set; }
public string CityName { get; set; }
public string CityCode { get; set; }
}
}
Test_BAL.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Test_DAL;
using Test_EL;
namespace Test_BAL
{
public class BusinessTier
{
DataTier dTier = new DataTier();
public object GetGrid()
{
return dTier.GetGrid();
}
public object GetCountry()
{
return dTier.GetCountry();
}
public object GetState(EntityTier eTier)
{
return dTier.GetState(eTier);
}
public object GetCity(EntityTier eTier)
{
return dTier.GetCity(eTier);
}
public Boolean InsUpdtValues(EntityTier eTier)
{
return dTier.InsertUpdateValues(eTier);
}
public Boolean DelValues(EntityTier eTier)
{
return dTier.DeleteValues(eTier);
}
}
}
Test_DAL.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Configuration;
using System.Data;
using System.Data.SqlClient;
using Test_EL;
namespace Test_DAL
{
public class DataTier
{
string conStr = ConfigurationManager.ConnectionStrings["testCon"].ConnectionString;
SqlConnection con;
SqlCommand cmd;
SqlDataAdapter sqlda;
DataTable dt;
DataSet ds;
public object GetGrid()
{
using (con = new SqlConnection(conStr))
{
con.Open();
string selQry = "sp_Test_Select_ddl";
using (cmd = new SqlCommand(selQry, con))
{
sqlda = new SqlDataAdapter(cmd);
dt = new DataTable();
sqlda.Fill(dt);
}
}
return dt;
}
public object GetCountry()
{
using (con = new SqlConnection(conStr))
{
con.Open();
string selCtry = string.Format("select * from test_country");
using (cmd = new SqlCommand(selCtry, con))
{
sqlda = new SqlDataAdapter(cmd);
dt = new DataTable();
sqlda.Fill(dt);
}
}
return dt;
}
public object GetState(EntityTier eTier)
{
using (con = new SqlConnection(conStr))
{
con.Open();
string selState = string.Format("select * from test_state where Ccode='{0}'", eTier.CountryCode);
using (cmd = new SqlCommand(selState, con))
{
sqlda = new SqlDataAdapter(cmd);
dt = new DataTable();
sqlda.Fill(dt);
}
}
return dt;
}
public object GetCity(EntityTier eTier)
{
using (con = new SqlConnection(conStr))
{
con.Open();
string selCity = string.Format("select * from test_city where SCode='{0}'", eTier.StateCode);
using (cmd = new SqlCommand(selCity, con))
{
sqlda = new SqlDataAdapter(cmd);
dt = new DataTable();
sqlda.Fill(dt);
}
}
return dt;
}
public Boolean InsertUpdateValues(EntityTier eTier)
{
using (con = new SqlConnection(conStr))
{
con.Open();
string insQry = "sp_Test_Insert";
using (cmd = new SqlCommand(insQry, con))
{
cmd.CommandType = CommandType.StoredProcedure;
if (eTier.PID > 0)
{
cmd.Parameters.AddWithValue("@perID", eTier.PID);
}
else
{
cmd.Parameters.AddWithValue("@perID", eTier.PID);
}
cmd.Parameters.AddWithValue("@perName", eTier.PName);
cmd.Parameters.AddWithValue("@CountryCode", eTier.CountryCode);
cmd.Parameters.AddWithValue("@StateCode", eTier.StateCode);
cmd.Parameters.AddWithValue("@CityCode", eTier.CityCode);
cmd.ExecuteNonQuery();
}
}
return true;
}
public Boolean DeleteValues(EntityTier eTier)
{
using (con = new SqlConnection(conStr))
{
con.Open();
string delQry = string.Format("delete from test_Person where PID={0}", eTier.PID);
using (cmd = new SqlCommand(delQry, con))
{
cmd.ExecuteNonQuery();
}
}
return true;
}
}
}
Web.config:
<connectionStrings>
<add name="testCon" connectionString="data source=test-PC;user id=PC;password=testPC;Initial Catalog=test;Persist Security Info=True;" providerName="System.Data.SqlClient"/>
</connectionStrings>
Custom GirdView control for Windows Forms
ReplyDelete