private void load_uname()
SqlConnection con = new SqlConnection(constring);
string sql = "select [uname] from user_registration where usergroup ='" + usertype.SelectedValue.ToString() + "' ";
SqlCommand cmd = new SqlCommand(sql, con);
dr = cmd.ExecuteReader();
this is my code which is not working if i put my query statically like this "select [uname] from user_registration where usergroup ='owners'", it's working but if i tried dynamically like above query in the code not fetching the data!!
You are expecting a string value wheras SelecetedValue will fetch for the Value against the string data given.
Say your Owners has 2 persons XYZ with ID 100 and ABC with ID 200
CASE 1:Selected value will search in owners by 100 or 200.
CASE 2:Selected Item will search in owners by XYZ OR ABC.
Since your are searching through string but you have specified Selected Value, it is showing blank.
Try case 2, it will work
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)