Hi,
on my webform, I have one grid, 2 dropdownlist and one datepicker control.
When I select items from my both dropdown and date from datepicker control, I want to populate my grid based on above mention control selections.
But, my problem is on selection, my grid is not showing any data.
Please help.
Code I am using is below: ASPX.CODE
<asp:DropDownList ID="ddlmenutype" OnSelectedIndexChanged ="ddlmenutype_SelectedIndexChanged" runat="server" Height="20px" Width="90px" AutoPostBack="True" ToolTip="Select Menu Type" ForeColor="Black" Font-Size="12px"> <asp:ListItem Value="B">BreakFast</asp:ListItem> <asp:ListItem Value="L">Lunch</asp:ListItem> <asp:ListItem Value="A">AlaCarte</asp:ListItem> <asp:ListItem Value="M">BreakFast-F</asp:ListItem> <asp:ListItem Value="N">Lunch-F</asp:ListItem> </asp:DropDownList>
<%@ Page Title="" Language="vb" AutoEventWireup="True" MasterPageFile="~/Dss.Master" CodeBehind="ProductionRecordmain.aspx.vb" Inherits="DSS.ProductionRecordmain" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
<asp:DropDownList
ID="ddlmenutype" OnSelectedIndexChanged ="ddlmenutype_SelectedIndexChanged" runat="server"
Height="20px" Width="90px" AutoPostBack="True" ToolTip="Select Menu Type" ForeColor="Black"
Font-Size="12px">
<asp:ListItem Value="B">Br</asp:ListItem>
<asp:ListItem Value="L">Lu</asp:ListItem>
<asp:ListItem Value="A">Al</asp:ListItem>
<asp:ListItem Value="M">BrF</asp:ListItem>
<asp:ListItem Value="N">LuF</asp:ListItem>
</asp:DropDownList>
<asp:DropDownList
ID="ddlSch" runat="server" Height="20px" Width="203px" AutoPostBack="True" Font-Size="12px"
>
</asp:DropDownList>
<telerik:RadDatePicker
ID="RadDatePick" Runat="server" AutoPostBack="True" Culture="en-US"
Skin="Outlook" Width="100px" Font-Size="10px" ForeColor="Black">
<Calendar runat="server" UseRowHeadersAsSelectors="False" UseColumnHeadersAsSelectors="False" ViewSelectorText="x"
Skin="Outlook"></Calendar>
<DateInput runat ="server" DisplayDateFormat="M/d/yyyy" DateFormat="M/d/yyyy" AutoPostBack="True"></DateInput>
<DatePopupButton ImageUrl="" HoverImageUrl=""></DatePopupButton>
</telerik:RadDatePicker>
<telerik:RadGrid ID="GD_Prod" runat="server" AllowPaging="True" AutoGenerateColumns="False"
GridLines="None" Height="261px" ShowHeader="False" Skin="Outlook" Width="1107px"
AllowAutomaticInserts="True" AllowAutomaticUpdates="True">
<ClientSettings AllowColumnsReorder="True" ReorderColumnsOnClient="True">
<Selecting AllowRowSelect="True" />
<Scrolling AllowScroll="True" UseStaticHeaders="True" />
</ClientSettings>
<MasterTableView CommandItemDisplay="Bottom"
EditMode="PopUp" InsertItemPageIndexAction="ShowItemOnCurrentPage">
<CommandItemSettings
AddNewRecordText="Add New item" ShowRefreshButton="False"></CommandItemSettings>
<RowIndicatorColumn>
<HeaderStyle Width="20px"></HeaderStyle>
</RowIndicatorColumn>
<ExpandCollapseColumn>
<HeaderStyle Width="20px"></HeaderStyle>
</ExpandCollapseColumn>
<Columns>
<telerik:GridBoundColumn DataField="port_recipe_num"
HeaderText="port_recipe_num" SortExpression="port_recipe_num"
UniqueName="port_recipe_num">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="DESC_ALT" HeaderText="DESC_ALT"
SortExpression="DESC_ALT" UniqueName="DESC_ALT">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="port_no_servings"
HeaderText="port_no_servings" SortExpression="port_no_servings"
UniqueName="port_no_servings">
</telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField="STD_NUM_OF_SERVING" DataType="System.Int32"
HeaderText="STD_NUM_OF_SERVING" SortExpression="STD_NUM_OF_SERVING"
UniqueName="STD_NUM_OF_SERVING">
</telerik:GridBoundColumn>
</Columns>
</MasterTableView>
</telerik:RadGrid>
VB CODE:
Imports System.Data
Imports System.Configuration
Imports System.Web
Imports System.Web.Security
Imports System.Web.UI
Imports System.Web.UI.WebControls
Imports System.Web.UI.WebControls.WebParts
Imports System.Web.UI.HtmlControls
Imports System.Data.SqlClient
Imports Telerik.Web.UI
Public Class ProductionRecordmain
Inherits System.Web.UI.Page
Public Sub BindGrid()
Dim con1 As New SqlConnection(ConfigurationManager.ConnectionStrings("myConnectionString").ConnectionString)
Dim cmd1 As New SqlCommand
Dim ada1 As New SqlDataAdapter("FN_PR_GetRec", con1)
Dim ds1 As New DataSet
con1.Open()
ada1.SelectCommand.CommandType = CommandType.StoredProcedure
cmd1.Parameters.Add("@RadDatePick", SqlDbType.DateTime).Direction = ParameterDirection.Input
cmd1.Parameters("@RadDatePick").Value = RadDatePick.SelectedDate
cmd1.Parameters.Add("@ddlSch", SqlDbType.Char).Direction = ParameterDirection.Input
cmd1.Parameters("@ddlSch").Value = ddlSch.SelectedValue
cmd1.Parameters.Add("@ddlMenuType", SqlDbType.Char).Direction = ParameterDirection.Input
cmd1.Parameters("@ddlMenuType").Value = ddlmenutype.SelectedValue
ada1.Fill(ds1, "FN_PR_GetRec")
con1.Close()
Dim dv As DataView = ds1.Tables(0).DefaultView
GD_Prod.DataSource = dv
Private Sub ddlSch_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles ddlSch.Load
Dim Conn As New SqlConnection(ConfigurationManager.ConnectionStrings("myConnectionString").ConnectionString)
Dim cmd As New SqlCommand
Dim ada As New SqlDataAdapter("FN_PR_SchName", Conn)
Dim ds As New DataSet
ada.SelectCommand.CommandType = CommandType.StoredProcedure
ada.Fill(ds, "FN_PR_SchName")
ddlSch.DataSource = ds
ddlSch.DataTextField = "LOCATION_NAME"
ddlSch.DataBind()
End Sub
Private Sub ddlmenutype_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles ddlmenutype.SelectedIndexChanged
If Not IsPostBack Then
BindGrid()
GD_Prod.DataBind()
End If
End Sub
Private Sub ddlSch_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles ddlSch.SelectedIndexChanged
If Not IsPostBack Then
BindGrid()
GD_Prod.DataBind()
End If
End Sub
Private Sub RadDatePick_SelectedDateChanged(ByVal sender As Object, ByVal e As Telerik.Web.UI.Calendar.SelectedDateChangedEventArgs) Handles RadDatePick.SelectedDateChanged
If Not IsPostBack Then
BindGrid()
GD_Prod.DataBind()
End If
End Sub
Private Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If Not IsPostBack Then
BindGrid()
GD_Prod.DataBind()
End If
End Sub
Private Sub GD_Prod_PageIndexChanged(ByVal sender As Object, ByVal e As Telerik.Web.UI.GridPageChangedEventArgs) Handles GD_Prod.PageIndexChanged
GD_Prod.CurrentPageIndex = e.NewPageIndex
BindGrid()
GD_Prod.DataBind()
End Sub
End Class