Last post Apr 09, 2014 11:05 AM by nat06
Member
60 Points
547 Posts
Apr 09, 2014 10:42 AM|nat06|LINK
Hi,
I have this code, and I connected the SelectedIndexChanged event to the DropDownList but on selecting an item it doesn't do anything:
protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e) { String Ime = DropDownList1.SelectedItem.Value.Trim(); SqlCommand inSqlCommand = new SqlCommand("listIncidents", conn); inSqlCommand.CommandType = CommandType.StoredProcedure; SqlParameter inParameter = new SqlParameter ("@Iname", SqlDbType.NVarChar, 60); inParameter.Direction = ParameterDirection.Input; inParameter.Value = Ime; inSqlCommand.Parameters.Add(inParameter); SqlDataReader inSqlDataReader; try { conn.Open(); inSqlDataReader = inSqlCommand.ExecuteReader(); while (inSqlDataReader.Read()) { txtName.Text = inSqlDataReader[0].ToString(); txtLattitude.Text = Convert.ToString(inSqlDataReader[2]); txtLongitude.Text = Convert.ToString(inSqlDataReader[1]); } inSqlDataReader.Close(); } catch (SqlException exc) { Response.Write(exc.ToString()); } catch (Exception ex) { Response.Write(ex.ToString()); } finally { conn.Close(); } }
Can anybody help me what might be wrong?
Thanks
All-Star
37441 Points
9076 Posts
Apr 09, 2014 10:48 AM|AidyF|LINK
The event fires when the form is submitted (ie the user clicks a submit button). If you want the event to fire right away then add the
AutoPostback="True"
attribute to your droplist.
50831 Points
9895 Posts
Apr 09, 2014 10:48 AM|A2H|LINK
Have you set DropDownList AutoPostBack property to true.if not please set it.
<asp:DropDownList ID="DropDownList1" runat="server" AutoPostBack="True" onselectedindexchanged="DropDownList1_SelectedIndexChanged"> </asp:DropDownList>
52523 Points
15678 Posts
Apr 09, 2014 11:00 AM|oned_gk|LINK
Apr 09, 2014 11:05 AM|nat06|LINK
Thanks to all of you
Member
60 Points
547 Posts
DropDownList_SelectedIndexChanged() doesn't work
Apr 09, 2014 10:42 AM|nat06|LINK
Hi,
I have this code, and I connected the SelectedIndexChanged event to the DropDownList but on selecting an item it doesn't do anything:
Can anybody help me what might be wrong?
Thanks
All-Star
37441 Points
9076 Posts
Re: DropDownList_SelectedIndexChanged() doesn't work
Apr 09, 2014 10:48 AM|AidyF|LINK
The event fires when the form is submitted (ie the user clicks a submit button). If you want the event to fire right away then add the
AutoPostback="True"
attribute to your droplist.
All-Star
50831 Points
9895 Posts
Re: DropDownList_SelectedIndexChanged() doesn't work
Apr 09, 2014 10:48 AM|A2H|LINK
Have you set DropDownList AutoPostBack property to true.if not please set it.
Aje
My Blog | Dotnet Funda
All-Star
52523 Points
15678 Posts
Re: DropDownList_SelectedIndexChanged() doesn't work
Apr 09, 2014 11:00 AM|oned_gk|LINK
Suwandi - Non Graduate Programmer
Member
60 Points
547 Posts
Re: DropDownList_SelectedIndexChanged() doesn't work
Apr 09, 2014 11:05 AM|nat06|LINK
Thanks to all of you