I have 3 related Dropdownlist in me Edit Form
I'm using the code below to bind the Dropdownlist but it will retrive the full list without the selected value saved and if i'm making a selected statment it will just retrive the selected value.
the dropdownlist is linked to other one so if the Category been saved as "Art" the Subject should retrive the saved Item the user selected earlier with the rest items for update purpose .
private void BindDrp_CAT()
{
using (SqlConnection con = new SqlConnection(myconn))
if (!IsPostBack)
{
SqlCommand com = new SqlCommand("select distinct Cat_name from tblCategory order by Cat_name ", con);
SqlDataReader dr;
con.Open();
Drp_CAT.Items.Clear();
dr = com.ExecuteReader();
while (dr.Read())
{
Drp_CAT.Items.Add(new ListItem(dr[0].ToString()));
}
con.Close();
}
}
Rohit KapdiPosted May 30, 2013, 3:17 AM
Can u share the app and write the page name on which u want the coding so i can help u out
ToBePosted May 28, 2013, 3:27 AM
Rohit KapdiPosted May 27, 2013, 6:21 AM
are u using the UserInfo.cs file which contain the variable and property.
and in edit.aspx.cs make 2 public method first two fill the drop down like BindDropDown()
after this 2nd method to bind the user filled information in to page like userBind()
and in the 2nd method write those line
create object of userInfo.cs like objuser
Drp_CAT.selectedItem.Text=objuser.cat //proprty_name regarding catagory
ToBePosted May 27, 2013, 3:19 AM
thanks for reply
didn't get u sorry where should i Put this : Drp_CAT.selecteditem.text="classobj.property"
in my up code ?
Rohit KapdiPosted May 27, 2013, 12:37 AM
if ur coding the edit form then first all the dropdown list with the data which they should contain in page load. then when u bind the other value which where entered by the user in that part of code just write below line
Drp_CAT.selecteditem.text="classobj.property"
(the object of the class and name of the property)
this will show the values which was submitted at first and will give other option for update.
if u dont get the line then please do share that page and the class library .cs file if ur using any one