I have a DropDownList which is filled up from database. When I select a record on index 1, it comes up with right results but when I select second index, it comes up with same index. it looks like DropDownList shows First Index as by default. How can I select change index in DropDownList?
So if would select index 3 the result must be from index 3.
I have tried DropDownList.SelectedItem,DropDownList.SelectedValue,DropDownList.SelectedIndex,DropDownList.Text but No effect seems to be there.
DropDownList Loading on Page_Load
public void load_Individual()
{
if (IsPostBack == false)
{
SqlDataAdapter sdaIndividual = new SqlDataAdapter("select * from tbl_trip", _connectionString);
DataTable dtIndividual = new DataTable();
sdaIndividual.Fill(dtIndividual);
if (dtIndividual.Rows.Count > 0)
{
ddl_Individual.DataTextField = "TruckNo";
ddl_Individual.DataValueField = "TruckNo";
ddl_Individual.DataSource = dtIndividual;
ddl_Individual.DataBind();
}
}
}
DropDownList For Selecting Values
if (ddl_Individual.Text != string.Empty)
{
ddl_Individual.ClearSelection();
adp = new SqlDataAdapter(@"Select * , '' as c1, '' as c2, 0 as c3 , 0 as c4 , 0 as c5 , 0 as c6, 0 as c7 , 0 as c8 from tbl_Trip
where TruckNo='" + ddl_Individual.SelectedValue + "'", _connectionString);
adp.Fill(Dt);
Session["mydata"] = Dt;
Response.Redirect("LoadReport.aspx");
}
else
{
ScriptManager.RegisterClientScriptBlock(this, this.GetType(),"alertMessage","aler('select valid value')", true);
}