NerishaB
asked on
ASP Dropdown Passing Databound selection value
Hi,
I have created an ASP dropdown, and used the wizard to bind the data to the list. Now, I want to pass the result back so that I may use it in the codebehind, but I dont know how to do this.
See my aspx code here: My Codebehind is attached below. I need to pass the selection in the "Submit" function.
<asp:DropDownList ID="DropDownList1" runat="server" DataSourceID="SqlDataSourc e1"
DataTextField="FullName" DataValueField="Personel_I D" Height="27px"
Width="218px" AutoPostBack="True"
onselectedindexchanged="Dr opDownList 1_Selected IndexChang ed"
AppendDataBoundItems="True ">
<asp:ListItem Text="(All)" Value="defaultValue" Selected="true"></asp:List Item>
</asp:DropDownList>
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="Connecti onString">
</asp:SqlDataSource>
I have created an ASP dropdown, and used the wizard to bind the data to the list. Now, I want to pass the result back so that I may use it in the codebehind, but I dont know how to do this.
See my aspx code here: My Codebehind is attached below. I need to pass the selection in the "Submit" function.
<asp:DropDownList ID="DropDownList1" runat="server" DataSourceID="SqlDataSourc
DataTextField="FullName" DataValueField="Personel_I
Width="218px" AutoPostBack="True"
onselectedindexchanged="Dr
AppendDataBoundItems="True
<asp:ListItem Text="(All)" Value="defaultValue" Selected="true"></asp:List
</asp:DropDownList>
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="Connecti
</asp:SqlDataSource>
protected void submit(object sender, EventArgs e)
{
Class1 c1 = new Class1();
DateTime FromDate= DateTime.Parse(Request.Form[TextBox1.UniqueID]);
DateTime toDate = DateTime.Parse(Request.Form[TextBox2.UniqueID]);
IDataReader reader = c1.getData(FromDate, toDate, FullName);
GridView1.DataSource = reader;
GridView1.DataBind();
In your casetry like thi s
string str = HttpContext.Current.Reques t.Form[var DropDownLi st.UniqueI D];
or
string str = Request.Form[varDropDownLi st.UniqueI D];
string str = HttpContext.Current.Reques
or
string str = Request.Form[varDropDownLi
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks
DropDownList1.SelectedItem