I have a drop down list which has the values of column's table.
and I have the following statement in c#:
string raf = string.Format("select Id from Customer WHERE email="dropdownlist1");
how can assign the value of the drop down list to email ?
try this
{0}
Means Your are fetching First Argument ofstring.Format
methodBeware of
SQL Injection
Always Use SQL ParametersYou need to use
.SelectedValue
property to fetch the value of dropdown:-For fetching dropdown text:-
Also, Note you need a place holder like
{0}
, when usingString.Format
.Though as per your query, you are mostly hitting a database, so beware of SQL Injection, use parameterized query like this:-