Hi friends..
Im trying to bind a value from dropdownlist placed in gird view to another cell. i want to update a database field with the selected value from dropdownlist and which must be bind to gridview... please help me .. im using sql server2000 as datasource..
public partial class Propertydetails : System.Web.UI.P age
{
protected static string connect;
string ct, struName;
protected void Page_Load(objec t sender, EventArgs e)
{
string username = Session["UserName"].ToString();
connect = System.Configur ation.Configura tionManager.App Settings["connect"];
SqlConnection con = new SqlConnection() ;
con.ConnectionS tring = connect;
con.Open();
string s = "select PM.RegisterID,P M.PropertyID,PR .PropertyName,C D.CategoryName from PropertyMember PM,Property PR,CategoryDeta ils CD where PM.UserName='" + username + "'and PM.PropertyID=P R.PropertyID and CD.CategoryType =PM.CategoryTyp e";
SqlDataSource1. ConnectionStrin g = connect;
SqlDataSource1. SelectCommand = s;
con.Close();
}
protected void DropDownList2_S electedIndexCha nged(object sender, EventArgs e)
{
// DropDownList ddl1 = new DropDownList();
// //ddl1 = (DropDownList)G ridView1.Select edRow.FindContr ol("DropDownLis t1");
// cname = ddl1.SelectedVa lue.ToString();
// Session["cname1"] = cname;
}
protected void GridView1_RowUp dating(object sender, GridViewUpdateE ventArgs e)
{
string username = Session["UserName"].ToString();
SqlConnection con = new SqlConnection(c onnect);
string select = "Select CategoryType from CategoryDetails where CategoryName='" + struName + "'";
SqlDataReader dr = null;
SqlCommand cmd1 = new SqlCommand(sele ct, con);
con.Open();
dr = cmd1.ExecuteRea der();
while (dr.Read())
{
struName = dr[0].ToString();
}
struName = ((DropDownList) ((GridView)send er).Rows[e.RowIndex].FindControl("D ropDownList1")) .SelectedValue;
e.NewValues["CategoryNa me"] = struName;
e.Cancel = false;
con.Close();
}
}
please help me..
thanks for all kind of support
Im trying to bind a value from dropdownlist placed in gird view to another cell. i want to update a database field with the selected value from dropdownlist and which must be bind to gridview... please help me .. im using sql server2000 as datasource..
public partial class Propertydetails : System.Web.UI.P age
{
protected static string connect;
string ct, struName;
protected void Page_Load(objec t sender, EventArgs e)
{
string username = Session["UserName"].ToString();
connect = System.Configur ation.Configura tionManager.App Settings["connect"];
SqlConnection con = new SqlConnection() ;
con.ConnectionS tring = connect;
con.Open();
string s = "select PM.RegisterID,P M.PropertyID,PR .PropertyName,C D.CategoryName from PropertyMember PM,Property PR,CategoryDeta ils CD where PM.UserName='" + username + "'and PM.PropertyID=P R.PropertyID and CD.CategoryType =PM.CategoryTyp e";
SqlDataSource1. ConnectionStrin g = connect;
SqlDataSource1. SelectCommand = s;
con.Close();
}
protected void DropDownList2_S electedIndexCha nged(object sender, EventArgs e)
{
// DropDownList ddl1 = new DropDownList();
// //ddl1 = (DropDownList)G ridView1.Select edRow.FindContr ol("DropDownLis t1");
// cname = ddl1.SelectedVa lue.ToString();
// Session["cname1"] = cname;
}
protected void GridView1_RowUp dating(object sender, GridViewUpdateE ventArgs e)
{
string username = Session["UserName"].ToString();
SqlConnection con = new SqlConnection(c onnect);
string select = "Select CategoryType from CategoryDetails where CategoryName='" + struName + "'";
SqlDataReader dr = null;
SqlCommand cmd1 = new SqlCommand(sele ct, con);
con.Open();
dr = cmd1.ExecuteRea der();
while (dr.Read())
{
struName = dr[0].ToString();
}
struName = ((DropDownList) ((GridView)send er).Rows[e.RowIndex].FindControl("D ropDownList1")) .SelectedValue;
e.NewValues["CategoryNa me"] = struName;
e.Cancel = false;
con.Close();
}
}
please help me..
thanks for all kind of support
Comment