As I can see your question, you need to modify a couple of things here:
1. Change in aspx:
<asp:dropdownlist id="DropDownList1" runat="server" xmlns:asp="#unknown">
onselectedindexchanged="DropDownList1_SelectedIndexChanged"
AutoPostBack="True">
<asp:listitem value=""> --Select--</asp:listitem>
<asp:listitem value="ClientName"> ClientName</asp:listitem>
<asp:listitem value="DeliveryDate"> DeliveryDate</asp:listitem>
<asp:listitem value="ExtendDate"> ExtendDate</asp:listitem>
</asp:dropdownlist>
Always try to add a value with the
ListItems
, so that while validating you won't get any problem.
2. Change in CS:
protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
{
if(DropDownList1.SeletedValue != ""){
cmd = new SqlCommand("selectDataByDDLValue", con);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.AddWithValue("@ddlValue", DropDownList1.SelectedValue);
SqlDataAdapter sda = new SqlDataAdapter(cmd);
DataSet ds = new DataSet();
sda.Fill(ds);
GridView2.DataSource = ds.Tables[0];
GridView2.DataBind();
sda.Dispose();
cmd.Dispose();
con.Close();
}
}
All the best.
--Amit