I want display some datas in gridview based on dropdown selected value
<asp:DropDownList ID="ddlStatus" runat="server" AutoPostBack="true"
onselectedindexchanged="ddlStatus_SelectedIndexChanged">
<asp:ListItem>NewOrder</asp:ListItem>
<asp:ListItem>Ready</asp:ListItem>
<asp:ListItem>Canceled</asp:ListItem>
<asp:ListItem>Shipped</asp:ListItem>
<asp:ListItem>Delivered</asp:ListItem>
</asp:DropDownList>
<asp:GridView ID="GridView1" runat="server" CellPadding="4" GridLines="None"
DataKeyNames="OrderId" ForeColor="#333333" Style="position: static"
AutoGenerateColumns="False" CssClass="gridview"
onrowdeleting="GridView1_RowDeleting" AllowPaging="True" PageSize="5"
onpageindexchanging="GridView1_PageIndexChanging" onrowediting="EditCustomer"
onrowupdating="UpdateCustomer"
onrowcancelingedit="GridView1_RowCancelingEdit"
onrowdatabound="GridView1_RowDataBound">
<FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
<RowStyle BackColor="#EFF3FB" />
<EditRowStyle BackColor="#2461BF" />
<SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" />
<PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center" />
<HeaderStyle BackColor="#507CD1" Font-Bold="True" ForeColor="Lime" />
<AlternatingRowStyle BackColor="White" />
<Columns>
<asp:TemplateField HeaderText="Order No">
<ItemTemplate>
<asp:Label ID="lblno" runat="server" Text='<%#Eval("OrderId") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Customer Name">
<ItemTemplate>
<asp:Label ID="Custname" runat="server" Text='<%#Eval("UserName") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Image">
<ItemTemplate>
<asp:Image ID="image" runat="server" ImageUrl='<%# "GridviewImage.ashx?ImID=" + Eval("productid")%>' Width="100" Height="100" />
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="OrderDate">
<ItemTemplate>
<asp:Label ID="bname" runat="server" Text='<%#Eval("OrderDate") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Price">
<ItemTemplate>
<asp:Label ID="cost" runat="server" Text='<%#Eval("OrderAmount") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText = "Order Status">
<ItemTemplate>
<asp:Label ID="lblstatus" runat="server" Text='<%# Eval("StatusDescription")%>'></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:Label ID="lblstatus" runat="server" Text='<%# Eval("StatusDescription")%>' Visible = "false"></asp:Label>
<asp:DropDownList ID = "ddlstatus" runat = "server">
<asp:ListItem>New Order</asp:ListItem>
<asp:ListItem>Ready</asp:ListItem>
<asp:ListItem>Canceled</asp:ListItem>
<asp:ListItem>Shipped</asp:ListItem>
<asp:ListItem>Delivered</asp:ListItem>
</asp:DropDownList>
</EditItemTemplate>
</asp:TemplateField>
<asp:CommandField ShowEditButton="True" />
</Columns>
<EmptyDataTemplate>
<strong>There are no Orders.</strong>
</EmptyDataTemplate>
</asp:GridView>
My cs code as
private void BindDatastatus()
{
try
{
SqlCommand com = new SqlCommand("rsa_products_sp_GetadminordersortbyStatus", con);
com.CommandType = CommandType.StoredProcedure;
string stat = ddlStatus.SelectedValue.ToString();
com.Parameters.AddWithValue("@status", stat);
da = new SqlDataAdapter(com);
ds = new DataSet();
da.Fill(ds);
GridView1.DataSource = ds;
GridView1.DataBind();
GridView1.Attributes.Add("bordercolor", "black");
}
catch (Exception ex)
{
}
}
protected void ddlStatus_SelectedIndexChanged(object sender, EventArgs e)
{
try
{
BindDatastatus();
}
catch (Exception ex)
{
}
}
My stored Procedure
CREATE proc [dbo].[rsa_products_sp_GetadminordersortbyStatus] (@status varchar)
as
select OrderId,
OrderDate,OrderAmount,StatusDescription,productid,
isnull((Select [UserName] from rsa_Users WHERE [UserId]=rsa_Order.UserId),'NA')'UserName',
isnull(NetAmount,0)'NetAmount'
from rsa_Order
where active=1 and StatusDescription=@status
GO
Its not showing anything in the grid what i'm doing wrong please help me to solve this.Thanks