error when selected value from ddl
I had DDL and when I selected on it this error apear (operator <
cannot be aplied with operand String
or int
)
if (DDlCity.SelectedValue < 0)
{
using (SqlConnection con = Connection.GetConnection())
{
SqlCommand Com = new SqlCommand("GetDealers", con);
Com.CommandType = CommandType.StoredProcedure;
SqlDataAdapter DA = new SqlDataAd开发者_JS百科apter(Com);
DA.Fill(DT);
GridView1.DataSource = DT;
GridView1.DataBind();
}
You need to convert DDlCity.SelectedValue
to an appropriate type - it sounds like it's currently string
. You'll need to parse it, e.g. with int.TryParse
or int.Parse
.
if (DDlCity.SelectedIndex<0)
精彩评论