SqlDataSource with Parameters

  1. #1

    SqlDataSource with Parameters

    Hi All,

    I am binding data to GridPanel by using Store and SqlDatSource Control. In a first page the grid control contains some data. if I want to see the details , i will clk on the button in GridPanel , then one popup window will open. here I'm displaying the details in GridPanel.

    for popup window GridPanel , I need to pass the ID to the SQLDatasource. here I'm not able to paas the Id.

    Can anyone please help me on this.


    Here am attaching the page snippets

    Here is the my code.

    .aspx
    --------------
    <%@ Page Language="VB" AutoEventWireup="false" CodeFile="PublicationSchedule.aspx.vb"
        Inherits="PublicationSchedule" %>
    
    <%@ Register Assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
        Namespace="System.Web.UI" TagPrefix="asp" %>
    <%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>
    <%@ Register Assembly="Coolite.Ext.Web" Namespace="Coolite.Ext.Web" TagPrefix="ext" %>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title>Untitled Page</title>
    
        <script type="text/javascript" language="javascript">
        
        
        var startEditing = function (e)
         {
                if (e.getKey() === e.ENTER) {
                    var grid = GridPanel1,
                        record = grid.getSelectionModel().getSelected(),
                        index = grid.store.indexOf(record);
                        
                    grid.startEditing(index, 1);
                }
            };
            
            var afterEdit = function (e) 
            {       
            
    //        alert(e.record.data.ID);
    //        alert(e.field);
    //        alert(e.originalValue);
    //        alert(e.value);
    //        alert(e.record.data);
            
                /*
                Properties of 'e' include:
                    e.grid - This grid
                    e.record - The record being edited
                    e.field - The field name being edited
                    e.value - The value being set
                    e.originalValue - The original value for the field, before the edit.
                    e.row - The grid row index
                    e.column - The grid column index
                */
                
                // Call DirectMethod
               Wizard.AfterEdit(e.record.data.ID, e.field, e.originalValue, e.value);
            };
    
        
        function ShoworHide(cntl)
        {
            switch(cntl)
            {
                case "Daily":
                    panelDaily.show();
                    panelWeekly.hide();
                    panelMonthly.hide();
                    PanelYearly.hide();
                       break;
                 case "Weekly":
                    panelDaily.hide();
                    panelWeekly.show();
                    panelMonthly.hide();
                     PanelYearly.hide();
                        break;
                 case "Monthly":
                    panelDaily.hide();
                    panelWeekly.hide();
                    panelMonthly.show();
                    PanelYearly.hide();
                       break;
                 case "Yearly":
                    panelDaily.hide();
                    panelWeekly.hide();
                    panelMonthly.hide();
                    PanelYearly.show();
    
    
                break;
            }
        }
        
        </script>
    
    </head>
    <body>
        <form id="form1" runat="server">
        <div>
            <ext:ScriptManager ID="ScriptManager1" runat="server" Theme="Slate">
            </ext:ScriptManager>
            <asp:ScriptManager ID="ScriptManager2" runat="server">
            </asp:ScriptManager>
            <asp:SqlDataSource ID="MagFrequencyIssueDataSource" runat="server" SelectCommand=" select ID, Name, Description, RecurrenceType from tblMagFrequencyIssueSet"
                UpdateCommand="update tblMagFrequencyIssueSet set name=@Name  , description = isnull(@Description,' ') where ID=@ID "
                ConnectionString="<%$ConnectionStrings:WizardConnstr%>">
                <UpdateParameters>
                    <asp:Parameter DbType="Int32" Name="ID" />
                    <asp:Parameter DbType="String" Name="Name" />
                    <asp:Parameter DbType="String" Name="Description" />
                </UpdateParameters>
            </asp:SqlDataSource>
            <ext:Store ID="MagFrequencyIssueStore" runat="server" DataSourceID="MagFrequencyIssueDataSource">
                <Reader>
                    <ext:JsonReader ReaderID="ID">
                        <Fields>
                            <ext:RecordField Name="ID">
                            </ext:RecordField>
                            <ext:RecordField Name="Name">
                            </ext:RecordField>
                            <ext:RecordField Name="Description">
                            </ext:RecordField>
                            <ext:RecordField Name="RecurrenceType">
                            </ext:RecordField>
                        </Fields>
                    </ext:JsonReader>
                </Reader>
            </ext:Store>
            <ext:GridPanel ID="GridPanel1" runat="server" StoreID="MagFrequencyIssueStore" AutoHeight="true"
                TrackMouseOver="true" StripeRows="true" AutoExpandColumn="Description" Title="Publication Schedule Details">
                <Listeners>
                    <KeyDown Fn="startEditing" />
                    <AfterEdit Fn="afterEdit" />
                </Listeners>
                <LoadMask ShowMask="true" />
                <ColumnModel ID="ColModel1" runat="server">
                    <Columns>
                        <ext:Column Header="Name" Sortable="true" DataIndex="Name" Width="300">
                            <Editor>
                                <ext:TextField ID="txtEditName" runat="server" MaxLength="250" AllowBlank="false"
                                    BlankText="Please enter schedule name">
                                </ext:TextField>
                            </Editor>
                        </ext:Column>
                        <ext:Column Header="Description" Sortable="true" DataIndex="Description" Wrap="true">
                            <Editor>
                                <ext:TextArea ID="txaEditDesc" runat="server" AllowBlank="false" BlankText="Please enter description"
                                    CausesValidation="true">
                                </ext:TextArea>
                            </Editor>
                        </ext:Column>
                        <ext:CommandColumn Width="110">
                            <Commands>
                                <ext:GridCommand Text="View Issues" StandOut="true" CommandName="Edit">
                                    <ToolTip Text="Click to view the issues" />
                                </ext:GridCommand>
                            </Commands>
                        </ext:CommandColumn>
                    </Columns>
                </ColumnModel>
                <SelectionModel>
                    <ext:RowSelectionModel runat="server" SingleSelect="true">
                    </ext:RowSelectionModel>
                </SelectionModel>
                <AjaxEvents>
                    <Command OnEvent="Command">
                        <ExtraParams>
                            <ext:Parameter Name="id" Value="record.data.ID" Mode="Raw">
                            </ext:Parameter>
                            <ext:Parameter Name="name" Value="record.data.Name" Mode="Raw">
                            </ext:Parameter>
                        </ExtraParams>
                    </Command>
                </AjaxEvents>
                <BottomBar>
                    <ext:PagingToolbar ID="PagingToolbar1" runat="server" PageSize="10" StoreID="MagFrequencyIssueStore"
                        DisplayInfo="true" />
                </BottomBar>
            </ext:GridPanel>
            <br />
            <ext:Button ID="btnNew" runat="server" Text="Add Schedule" Icon="Add">
                <Listeners>
                    <Click Handler="Window2.show();" />
                </Listeners>
            </ext:Button>
            <ext:Window ID="Window2" runat="server" Icon="House" Title="Add Schedule" Hidden="true"
                ShowOnLoad="false" Modal="true" AutoHeight="true" Width="500">
                <LoadMask ShowMask="true" />
                <Body>
                    <ext:Panel ID="Panel2" runat="server" Frame="true" Title="" AutoWidth="true">
                        <Body>
                            <table height="100%" cellspacing="0" cellpadding="4" width="100%" border="0">
                                <tr>
                                    <td valign="top" align="center">
                                        <table border="0">
                                            <tr>
                                                <td class="x-panel-header" align="center" colspan="4">
                                                    <asp:Label ID="lblHeader" runat="server"></asp:Label>
                                                </td>
                                            </tr>
                                            <tr>
                                                <td class="x-toolbar x-small-editor" align="center" colspan="4" style="color: White;
                                                    font: 13px tahoma arial verdana sans-serif">
                                                    Schedule Information
                                                </td>
                                            </tr>
                                            <tr>
                                                <td class="x-menu-list-item" align="right" colspan="1">
                                                    Schedule Name:
                                                </td>
                                                <td class="item" align="left" colspan="2">
                                                    <asp:TextBox ID="txtName" runat="server" MaxLength="100"></asp:TextBox>
                                                    <asp:RequiredFieldValidator ID="rfvNama" runat="server" ControlToValidate="txtName"
                                                        ErrorMessage="Please enter schedule name" Display="Dynamic"></asp:RequiredFieldValidator>
                                                </td>
                                                <td>
                                                </td>
                                            </tr>
                                            <tr>
                                                <td class="x-menu-list-item" align="right" colspan="1">
                                                    Description:
                                                </td>
                                                <td class="x-menu-list-item" align="left" colspan="2">
                                                    <asp:TextBox ID="txtDesc" runat="server" MaxLength="60" TextMode="MultiLine"></asp:TextBox>
                                                    <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="txtDesc"
                                                        ErrorMessage="Please enter schedule description" Display="Dynamic"></asp:RequiredFieldValidator>
                                                </td>
                                                <td>
                                                </td>
                                            </tr>
                                            <tr>
                                                <td class="x-toolbar x-small-editor" align="center" colspan="4" style="color: White;
                                                    font: 13px tahoma arial verdana sans-serif">
                                                    Schedule Start
                                                </td>
                                            </tr>
                                            <tr>
                                                <td class="x-menu-list-item" align="right">
                                                    Start Date:
                                                </td>
                                                <td class="x-menu-list-item" align="left">
                                                    <asp:TextBox ID="txtStartDate" runat="server" Columns="8"></asp:TextBox>
                                                    <asp:ImageButton ID="imgStartDate" runat="server" ImageUrl="~/CSS/img/calender.png"
                                                        CausesValidation="False" />
                                                    <cc1:MaskedEditExtender ID="txtStartDate_MaskedEditExtender" runat="server" TargetControlID="txtStartDate"
                                                        Mask="99/99/9999" MessageValidatorTip="true" OnFocusCssClass="MaskedEditFocus"
                                                        OnInvalidCssClass="MaskedEditError" MaskType="Date" DisplayMoney="Left" AcceptNegative="Left"
                                                        ErrorTooltipEnabled="True" Century="2000" ClearTextOnInvalid="True">
                                                    </cc1:MaskedEditExtender>
                                                    <cc1:MaskedEditValidator ID="txtStartDate_MaskedEditValidator" runat="server" ControlExtender="txtStartDate_MaskedEditExtender"
                                                        ControlToValidate="txtStartDate" InvalidValueMessage="Date is invalid" Display="None"
                                                        InvalidValueBlurredMessage="" ValidationGroup="" SetFocusOnError="True">
                                                    </cc1:MaskedEditValidator>
                                                    <cc1:CalendarExtender ID="txtStartDate_CalendarExtender" runat="server" Enabled="True"
                                                        TargetControlID="txtStartDate" Animated="True" PopupButtonID="imgStartDate">
                                                    </cc1:CalendarExtender>
                                                </td>
                                                <td class="item" align="right">
                                                </td>
                                                <td class="item" align="left">
                                                </td>
                                            </tr>
                                            <tr>
                                                <td class="x-toolbar x-small-editor" align="center" colspan="4" style="color: White;
                                                    font: 13px tahoma arial verdana sans-serif">
                                                    Schedule Frequency
                                                </td>
                                            </tr>
                                            <tr>
                                                <td class="x-menu-list-item" align="right">
                                                    <ext:RadioGroup ID="rdoRecurrenceType" runat="server" FieldLabel="Single Column"
                                                        ColumnsNumber="1">
                                                        <Items>
                                                            <ext:Radio ID="Radio9" runat="server" BoxLabel="Daily">
                                                                <Listeners>
                                                                    <Check Delay="0" Handler="ShoworHide('Daily');" />
                                                                </Listeners>
                                                            </ext:Radio>
                                                            <ext:Radio ID="Radio10" runat="server" BoxLabel="Weekly">
                                                                <Listeners>
                                                                    <Change Delay="0" Handler="ShoworHide('Weekly');" />
                                                                </Listeners>
                                                            </ext:Radio>
                                                            <ext:Radio ID="Radio11" runat="server" BoxLabel="Monthly" Checked="true">
                                                                <Listeners>
                                                                    <Change Delay="0" Handler="ShoworHide('Monthly');" />
                                                                </Listeners>
                                                            </ext:Radio>
                                                            <ext:Radio ID="Radio1" runat="server" BoxLabel="Yearly">
                                                                <Listeners>
                                                                    <Change Delay="0" Handler="ShoworHide('Yearly');" />
                                                                </Listeners>
                                                            </ext:Radio>
                                                        </Items>
                                                    </ext:RadioGroup>
                                                    <%--<asp:RadioButtonList ID="" runat="server" AutoPostBack="True" CssClass="x-menu-list-item">
                                                        <asp:ListItem Value="Daily">Daily</asp:ListItem>
                                                        <asp:ListItem Value="Weekly">Weekly</asp:ListItem>
                                                        <asp:ListItem Value="Monthly" Selected="True">Monthly</asp:ListItem>
                                                        <asp:ListItem Value="Yearly">Yearly</asp:ListItem>
                                                    </asp:RadioButtonList>--%>
                                                </td>
                                                <td class="x-menu-list-item" valign="top" align="left" colspan="3">
                                                    <ext:Panel ID="panelDaily" runat="server" Hidden="true" HideMode="Display">
                                                        <Body>
                                                        Every
                                                        <asp:TextBox ID="txtDays" runat="server" MaxLength="3" Columns="1">1</asp:TextBox>&nbsp;Day(s)
                                                    </Body>
                                                    </ext:Panel>
                                                    <%--<asp:Panel ID="panelDaily" runat="server" Visible="False">
                                                        Every
                                                        <asp:TextBox ID="txtDays" runat="server" MaxLength="3" Columns="1">1</asp:TextBox>&nbsp;Day(s)</asp:Panel>--%>
                                                    <ext:Panel ID="panelWeekly" runat="server" Hidden="true" HideMode="Display">
                                                        <Body>
                                                            <p>
                                                                Every
                                                                <asp:TextBox ID="txtWeeks" runat="server" MaxLength="3" Columns="1">2</asp:TextBox>&nbsp;Week(s)<br>
                                                                <asp:CheckBoxList ID="chkWeekDays" runat="server" RepeatColumns="5" RepeatLayout="Flow"
                                                                    RepeatDirection="Horizontal">
                                                                    <asp:ListItem Value="Monday">Monday</asp:ListItem>
                                                                    <asp:ListItem Value="Tuesday">Tuesday</asp:ListItem>
                                                                    <asp:ListItem Value="Wednesday">Wednesday</asp:ListItem>
                                                                    <asp:ListItem Value="Thursday">Thursday</asp:ListItem>
                                                                    <asp:ListItem Value="Friday">Friday</asp:ListItem>
                                                                    <asp:ListItem Value="Saturday">Saturday</asp:ListItem>
                                                                    <asp:ListItem Value="Sunday">Sunday</asp:ListItem>
                                                                </asp:CheckBoxList>
                                                            </p>
                                                        </Body>
                                                    </ext:Panel>
                                                    <ext:Panel ID="panelMonthly" runat="server">
                                                        <Body>
                                                            <table id="Table2" border="0">
                                                                <tr>
                                                                    <td class="x-menu-list-item" colspan="2">
                                                                        Every
                                                                        <asp:TextBox ID="txtMonths" runat="server" MaxLength="3" Columns="1">1</asp:TextBox>&nbsp;Month(s)
                                                                    </td>
                                                                </tr>
                                                                <tr>
                                                                    <td>
                                                                        <asp:RadioButton ID="rdoMonthDay" runat="server" Checked="True" GroupName="MonthlyGroup">
                                                                        </asp:RadioButton>
                                                                    </td>
                                                                    <td class="x-menu-list-item">
                                                                        Day
                                                                        <asp:DropDownList ID="ddlMonthDay" runat="server">
                                                                            <asp:ListItem Value="1">1</asp:ListItem>
                                                                            <asp:ListItem Value="2">2</asp:ListItem>
                                                                            <asp:ListItem Value="3">3</asp:ListItem>
                                                                            <asp:ListItem Value="4">4</asp:ListItem>
                                                                            <asp:ListItem Value="5">5</asp:ListItem>
                                                                            <asp:ListItem Value="6">6</asp:ListItem>
                                                                            <asp:ListItem Value="7">7</asp:ListItem>
                                                                            <asp:ListItem Value="8">8</asp:ListItem>
                                                                            <asp:ListItem Value="9">9</asp:ListItem>
                                                                            <asp:ListItem Value="10">10</asp:ListItem>
                                                                            <asp:ListItem Value="11">11</asp:ListItem>
                                                                            <asp:ListItem Value="12">12</asp:ListItem>
                                                                            <asp:ListItem Value="13">13</asp:ListItem>
                                                                            <asp:ListItem Value="14">14</asp:ListItem>
                                                                            <asp:ListItem Value="15">15</asp:ListItem>
                                                                            <asp:ListItem Value="16">16</asp:ListItem>
                                                                            <asp:ListItem Value="17">17</asp:ListItem>
                                                                            <asp:ListItem Value="18">18</asp:ListItem>
                                                                            <asp:ListItem Value="19">19</asp:ListItem>
                                                                            <asp:ListItem Value="20">20</asp:ListItem>
                                                                            <asp:ListItem Value="21">21</asp:ListItem>
                                                                            <asp:ListItem Value="22">22</asp:ListItem>
                                                                            <asp:ListItem Value="23">23</asp:ListItem>
                                                                            <asp:ListItem Value="24">24</asp:ListItem>
                                                                            <asp:ListItem Value="25">25</asp:ListItem>
                                                                            <asp:ListItem Value="26">26</asp:ListItem>
                                                                            <asp:ListItem Value="27">27</asp:ListItem>
                                                                            <asp:ListItem Value="28">28</asp:ListItem>
                                                                            <asp:ListItem Value="29">29</asp:ListItem>
                                                                            <asp:ListItem Value="30">30</asp:ListItem>
                                                                            <asp:ListItem Value="31">31</asp:ListItem>
                                                                            <asp:ListItem Value="last">last</asp:ListItem>
                                                                        </asp:DropDownList>
                                                                    </td>
                                                                </tr>
                                                                <tr>
                                                                    <td>
                                                                        <asp:RadioButton ID="rdoMonthPart" runat="server" GroupName="MonthlyGroup"></asp:RadioButton>
                                                                    </td>
                                                                    <td class="x-menu-list-item">
                                                                        The
                                                                        <asp:DropDownList ID="ddlWeekofMonth" runat="server">
                                                                            <asp:ListItem Value="1">first</asp:ListItem>
                                                                            <asp:ListItem Value="2">second</asp:ListItem>
                                                                            <asp:ListItem Value="3">third</asp:ListItem>
                                                                            <asp:ListItem Value="4">fourth</asp:ListItem>
                                                                            <asp:ListItem Value="last">last</asp:ListItem>
                                                                        </asp:DropDownList>
                                                                        <asp:DropDownList ID="ddlDayOfWeek" runat="server">
                                                                            <asp:ListItem Value="Monday">Monday</asp:ListItem>
                                                                            <asp:ListItem Value="Tuesday">Tuesday</asp:ListItem>
                                                                            <asp:ListItem Value="Wednesday">Wednesday</asp:ListItem>
                                                                            <asp:ListItem Value="Thursday">Thursday</asp:ListItem>
                                                                            <asp:ListItem Value="Friday">Friday</asp:ListItem>
                                                                            <asp:ListItem Value="Saturday">Saturday</asp:ListItem>
                                                                            <asp:ListItem Value="Sunday">Sunday</asp:ListItem>
                                                                        </asp:DropDownList>
                                                                    </td>
                                                                </tr>
                                                            </table>
                                                        </Body>
                                                    </ext:Panel>
                                                    <ext:Panel ID="PanelYearly" runat="server" Hidden="true" HideMode="Display">
                                                        <Body>
                                                            <table id="Table3" border="0">
                                                                <tr>
                                                                    <td class="item" colspan="2">
                                                                        Every&nbsp;
                                                                        <asp:TextBox ID="txtYears" runat="server" MaxLength="3" Columns="1">1</asp:TextBox>&nbsp;Year(s)
                                                                    </td>
                                                                </tr>
                                                                <tr>
                                                                    <td>
                                                                        <asp:RadioButton ID="rdoYearDay" runat="server" Checked="True" GroupName="YearlyGroup">
                                                                        </asp:RadioButton>
                                                                    </td>
                                                                    <td class="item">
                                                                        Day
                                                                        <asp:DropDownList ID="ddlYearMonth" runat="server">
                                                                            <asp:ListItem Value="1">January</asp:ListItem>
                                                                            <asp:ListItem Value="2">February</asp:ListItem>
                                                                            <asp:ListItem Value="3">March</asp:ListItem>
                                                                            <asp:ListItem Value="4">April</asp:ListItem>
                                                                            <asp:ListItem Value="5">May</asp:ListItem>
                                                                            <asp:ListItem Value="6">June</asp:ListItem>
                                                                            <asp:ListItem Value="7">July</asp:ListItem>
                                                                            <asp:ListItem Value="8">August</asp:ListItem>
                                                                            <asp:ListItem Value="9">September</asp:ListItem>
                                                                            <asp:ListItem Value="10">October</asp:ListItem>
                                                                            <asp:ListItem Value="11">November</asp:ListItem>
                                                                            <asp:ListItem Value="12">December</asp:ListItem>
                                                                        </asp:DropDownList>
                                                                        <asp:DropDownList ID="ddlYearMonthDay" runat="server">
                                                                            <asp:ListItem Value="1">1</asp:ListItem>
                                                                            <asp:ListItem Value="2">2</asp:ListItem>
                                                                            <asp:ListItem Value="3">3</asp:ListItem>
                                                                            <asp:ListItem Value="4">4</asp:ListItem>
                                                                            <asp:ListItem Value="5">5</asp:ListItem>
                                                                            <asp:ListItem Value="6">6</asp:ListItem>
                                                                            <asp:ListItem Value="7">7</asp:ListItem>
                                                                            <asp:ListItem Value="8">8</asp:ListItem>
                                                                            <asp:ListItem Value="9">9</asp:ListItem>
                                                                            <asp:ListItem Value="10">10</asp:ListItem>
                                                                            <asp:ListItem Value="11">11</asp:ListItem>
                                                                            <asp:ListItem Value="12">12</asp:ListItem>
                                                                            <asp:ListItem Value="13">13</asp:ListItem>
                                                                            <asp:ListItem Value="14">14</asp:ListItem>
                                                                            <asp:ListItem Value="15">15</asp:ListItem>
                                                                            <asp:ListItem Value="16">16</asp:ListItem>
                                                                            <asp:ListItem Value="17">17</asp:ListItem>
                                                                            <asp:ListItem Value="18">18</asp:ListItem>
                                                                            <asp:ListItem Value="19">19</asp:ListItem>
                                                                            <asp:ListItem Value="20">20</asp:ListItem>
                                                                            <asp:ListItem Value="21">21</asp:ListItem>
                                                                            <asp:ListItem Value="22">22</asp:ListItem>
                                                                            <asp:ListItem Value="23">23</asp:ListItem>
                                                                            <asp:ListItem Value="24">24</asp:ListItem>
                                                                            <asp:ListItem Value="25">25</asp:ListItem>
                                                                            <asp:ListItem Value="26">26</asp:ListItem>
                                                                            <asp:ListItem Value="27">27</asp:ListItem>
                                                                            <asp:ListItem Value="28">28</asp:ListItem>
                                                                            <asp:ListItem Value="29">29</asp:ListItem>
                                                                            <asp:ListItem Value="30">30</asp:ListItem>
                                                                            <asp:ListItem Value="31">31</asp:ListItem>
                                                                            <asp:ListItem Value="last">last</asp:ListItem>
                                                                        </asp:DropDownList>
                                                                    </td>
                                                                </tr>
                                                                <tr>
                                                                    <td>
                                                                        <asp:RadioButton ID="rdoYearPart" runat="server" GroupName="YearlyGroup"></asp:RadioButton>
                                                                    </td>
                                                                    <td class="item">
                                                                        The
                                                                        <asp:DropDownList ID="ddlWeekOfMonthYear" runat="server">
                                                                            <asp:ListItem Value="1">first</asp:ListItem>
                                                                            <asp:ListItem Value="2">second</asp:ListItem>
                                                                            <asp:ListItem Value="3">third</asp:ListItem>
                                                                            <asp:ListItem Value="4">fourth</asp:ListItem>
                                                                            <asp:ListItem Value="last">last</asp:ListItem>
                                                                        </asp:DropDownList>
                                                                        <asp:DropDownList ID="ddlDayOfWeekYear" runat="server">
                                                                            <asp:ListItem Value="Monday">Monday</asp:ListItem>
                                                                            <asp:ListItem Value="Tuesday">Tuesday</asp:ListItem>
                                                                            <asp:ListItem Value="Wednesday">Wednesday</asp:ListItem>
                                                                            <asp:ListItem Value="Thursday">Thursday</asp:ListItem>
                                                                            <asp:ListItem Value="Friday">Friday</asp:ListItem>
                                                                            <asp:ListItem Value="Saturday">Saturday</asp:ListItem>
                                                                            <asp:ListItem Value="Sunday">Sunday</asp:ListItem>
                                                                        </asp:DropDownList>
                                                                        of
                                                                        <asp:DropDownList ID="ddlMonthOfYear" runat="server">
                                                                            <asp:ListItem Value="1">January</asp:ListItem>
                                                                            <asp:ListItem Value="2">February</asp:ListItem>
                                                                            <asp:ListItem Value="3">March</asp:ListItem>
                                                                            <asp:ListItem Value="4">April</asp:ListItem>
                                                                            <asp:ListItem Value="5">May</asp:ListItem>
                                                                            <asp:ListItem Value="6">June</asp:ListItem>
                                                                            <asp:ListItem Value="7">July</asp:ListItem>
                                                                            <asp:ListItem Value="8">August</asp:ListItem>
                                                                            <asp:ListItem Value="9">September</asp:ListItem>
                                                                            <asp:ListItem Value="10">October</asp:ListItem>
                                                                            <asp:ListItem Value="11">November</asp:ListItem>
                                                                            <asp:ListItem Value="12">December</asp:ListItem>
                                                                        </asp:DropDownList>
                                                                    </td>
                                                                </tr>
                                                            </table>
                                                        </Body>
                                                    </ext:Panel>
                                                </td>
                                            </tr>
                                            <tr>
                                                <td class="item" align="right">
                                                </td>
                                                <td class="item" valign="top" align="left" colspan="3">
                                                </td>
                                            </tr>
                                            <tr>
                                                <td class="x-toolbar x-small-editor" align="center" colspan="4" style="color: White;
                                                    font: 13px tahoma arial verdana sans-serif">
                                                    Schedule End
                                                </td>
                                            </tr>
                                            <tr>
                                                <td align="center" colspan="4" style="border-color: Black; border-width: 1; border-style: solid">
                                                    <table id="Table1" cellspacing="0" cellpadding="0" width="100%" border="0">
                                                        <tr>
                                                            <td class="item" align="center">
                                                                <asp:RadioButton ID="rdoEndAfter" runat="server" Checked="True" GroupName="End" Text="End after">
                                                                </asp:RadioButton>
                                                                <asp:TextBox ID="txtEndAfter" runat="server" MaxLength="4" Columns="1">12</asp:TextBox>&nbsp;occurences
                                                            </td>
                                                            <td class="item" align="center">
                                                                <asp:RadioButton ID="rdoEndBy" runat="server" GroupName="End"></asp:RadioButton>End&nbsp;by
                                                                <asp:TextBox ID="txtEndOn" runat="server" Columns="12"></asp:TextBox>
                                                                <asp:ImageButton ID="imgEndOn" runat="server" ImageUrl="~/CSS/img/calender.png" CausesValidation="False" />
                                                                <cc1:MaskedEditExtender ID="txtEndOn_MaskedEditExtender" runat="server" TargetControlID="txtEndOn"
                                                                    Mask="99/99/9999" MessageValidatorTip="true" OnFocusCssClass="MaskedEditFocus"
                                                                    OnInvalidCssClass="MaskedEditError" MaskType="Date" DisplayMoney="Left" AcceptNegative="Left"
                                                                    ErrorTooltipEnabled="True" Century="2000" ClearTextOnInvalid="True">
                                                                </cc1:MaskedEditExtender>
                                                                <cc1:MaskedEditValidator ID="txtEndOn_MaskedEditValidator" runat="server" ControlExtender="txtEndOn_MaskedEditExtender"
                                                                    ControlToValidate="txtEndOn" InvalidValueMessage="Date is invalid" Display="None"
                                                                    InvalidValueBlurredMessage="" ValidationGroup="" SetFocusOnError="True">
                                                                </cc1:MaskedEditValidator>
                                                                <cc1:CalendarExtender ID="txtEndOn_CalendarExtender" runat="server" Enabled="True"
                                                                    TargetControlID="txtEndOn" Animated="True" PopupButtonID="imgEndOn">
                                                                </cc1:CalendarExtender>
                                                            </td>
                                                        </tr>
                                                    </table>
                                                </td>
                                            </tr>
                                            <tr>
                                                <td class="subheading" align="center" colspan="4">
                                                </td>
                                            </tr>
                                            <tr>
                                                <td align="center" colspan="4">
                                                </td>
                                            </tr>
                                            <tr>
                                                <td class="item" align="center" colspan="4">
                                                    <asp:Button ID="btnSave" runat="server" Text="Save" Width="50px" CssClass="x-btn">
                                                    </asp:Button>
                                                    <asp:Button ID="btnCancel" runat="server" Text="Cancel" Width="50px" CssClass="x-btn"
                                                        CausesValidation="false"></asp:Button>
                                                </td>
                                            </tr>
                                        </table>
                                    </td>
                                </tr>
                            </table>
                        </Body>
                    </ext:Panel>
                </Body>
            </ext:Window>
            <ext:Window ID="winIssueDetails" runat="server" Icon="House" Title="Issue set Details"
                Hidden="true" ShowOnLoad="false" Modal="true" Height="600" AutoScroll="true"
                Width="500">
                <LoadMask ShowMask="true" />
                <Body>
                    <ext:Panel ID="Panel1" runat="server" Frame="true" Title="" AutoWidth="true">
                        <Body>
                            <span class="x-panel-header-text">Publication Schedule Name:</span>
                            <ext:Label Cls="x-panel-header-text" ID="punName" runat="server">
                            </ext:Label>
                            <asp:SqlDataSource ID="issueDetailsDatasource" runat="server" ConnectionString="<%$ConnectionStrings:WizardConnstr%>"
                                SelectCommandType="Text" SelectCommand="select ID, IssueName, CONVERT(varchar, IssueDate,107) IssueDate from tblMagFrequency where IssueSet= @issueSetId"
                                OnSelecting="issueDetailsDatasource_Selecting">
                                <SelectParameters>
                                    <asp:Parameter DbType="String" Name="issueSetId" />
                                </SelectParameters>
                            </asp:SqlDataSource>
                            <ext:Store ID="storeIsuueDetails" runat="server" OnRefreshData="storeIsuueDetails_RefreshData">
                                                       
                                <Reader>
                                    <ext:JsonReader ReaderID="">
                                        <Fields>
                                            <ext:RecordField Name="ID">
                                            </ext:RecordField>
                                            <ext:RecordField Name="IssueName">
                                            </ext:RecordField>
                                            <ext:RecordField Name="IssueDate">
                                            </ext:RecordField>
                                        </Fields>
                                    </ext:JsonReader>
                                </Reader>
                            </ext:Store>
                            <ext:GridPanel ID="gplIssueSetDetails" runat="server" StoreID="storeIsuueDetails"
                                AutoWidth="true" AutoHeight="true">
                                <ColumnModel>
                                    <Columns>
                                        <ext:Column Header="Issue Name" DataIndex="IssueName">
                                        </ext:Column>
                                        <ext:Column Header="Issue Date" DataIndex="IssueDate">
                                        </ext:Column>
                                    </Columns>
                                </ColumnModel>
                            </ext:GridPanel>
                        </Body>
                    </ext:Panel>
                </Body>
            </ext:Window>
        </div>
        </form>
    </body>
    </html>
    ---------------------------------
    .aspx.cs
    --------------------------
    Imports System.Data
    Imports Coolite.Ext.Web
    Imports System.Data.Common
    Imports Microsoft.ApplicationBlocks.Data
    
    
    Partial Class PublicationSchedule
        Inherits System.Web.UI.Page
        Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    
            If Not Me.IsPostBack Then
                Dim PubID As Integer = -1
                If Not Request.QueryString("PubID") = Nothing Then PubID = Request.QueryString("PubID")
    
                If PubID = -1 Then
                    txtName.Text = "New Publication Schedule"
                    lblHeader.Text = "New Publication Schedule"
    
                Else
                    'get the issue set name
                    Dim issueset As New IssueSet
                    Dim ds As DataSet = issueset.GetIssueSetForZone(System.Configuration.ConfigurationManager.ConnectionStrings("WizardConnstr").ToString(), PubID)
                    txtName.Text = ds.Tables(0).Rows(0)("Name")
                    txtName.Enabled = False
                    lblHeader.Text = "Add to Publication Schedule"
                End If
    
                'initilize some variables
                txtStartDate.Text = String.Format("{0:d}", Today()) 'iFormatDate(Today(), Session("DateFormat")) 'need to replace Ajax datepicker first
                txtEndOn.Text = String.Format("{0:d}", Today().AddYears(1)) 'iFormatDate(Today().AddYears(1), Session("DateFormat")) 'need to replace Ajax datepicker first
    
            End If
        End Sub
    
        Public Sub rdoRecurrenceType_SelectedIndexChanged()
            panelDaily.Visible = False
            panelWeekly.Visible = False
            panelMonthly.Visible = False
            PanelYearly.Visible = False
    
            For Each radio As Radio In rdoRecurrenceType.CheckedItems
    
                Select Case radio.BoxLabel.ToLower
                    Case "daily"
                        panelDaily.Visible = True
                    Case "weekly"
                        panelWeekly.Visible = True
                    Case "monthly"
                        panelMonthly.Visible = True
                    Case "yearly"
                        PanelYearly.Visible = True
                End Select
    
            Next
    
    
    
    
    
    
    
        End Sub
    
    
        'we have changed the recurrence type, update the controls on the page
        'Private Sub rdoRecurrenceType_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles 
        '    panelDaily.Visible = False
        '    panelWeekly.Visible = False
        '    panelMonthly.Visible = False
        '    PanelYearly.Visible = False
    
        '    Select Case SelectedValue.ToLower
        '        Case "daily"
        '            panelDaily.Visible = True
        '        Case "weekly"
        '            panelWeekly.Visible = True
        '        Case "monthly"
        '            panelMonthly.Visible = True
        '        Case "yearly"
        '            PanelYearly.Visible = True
        '    End Select
        'End Sub
    
        'add the new issue set and all defined issues
        Private Sub btnSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSave.Click
            'save the new issue set
            Dim cs As String = System.Configuration.ConfigurationManager.ConnectionStrings("WizardConnstr").ToString()
            Dim issueset As New IssueSet
            Dim IssueSetID As Integer = -1
            Dim PubID As Integer = -1
    
            If (Not (issueset.CheckScheduleNameExists(txtName.Text))) Then
                If Not Request.QueryString("PubID") = Nothing Then PubID = Request.QueryString("PubID")
                If PubID <> -1 Then
                    Dim ds As DataSet = issueset.GetIssueSetForZone(cs, PubID)
                    IssueSetID = ds.Tables(0).Rows(0)("ID")
                End If
                Dim strRecurrenceType As String = String.Empty
    
                For Each radio As Radio In rdoRecurrenceType.CheckedItems
                    strRecurrenceType = radio.BoxLabel.ToLower
                Next
    
                If IssueSetID = -1 Then
                    IssueSetID = issueset.AddIssueSet(cs, txtName.Text, txtDesc.Text, strRecurrenceType)
                End If
    
                'If PubID = -1 And chkPub.Checked And txtPubName.Text.Length <> 0 Then
                '    'Add Zone
                '    PubID = issueset.AddPublication(cs, txtPubName.Text, IssueSetID)
                'End If
    
                'local variables
                Dim tempDate, tempDayOfWeek, StartDate, EndOn As DateTime
                Dim EndAfter, i As Integer
    
                'get the first occurnence
                StartDate = txtStartDate.Text
                tempDate = StartDate
    
                'do we end by a date or after occurences
                Dim EndByDate As Boolean = True
                If rdoEndAfter.Checked Then EndByDate = False
    
                'get the ending range for this schedule
                EndOn = txtEndOn.Text
                EndAfter = txtEndAfter.Text
    
                'initialize the issue number for the 
    
                Select Case strRecurrenceType.ToLower
                    Case "daily"
                        'get the day frequency
                        Dim days As Integer = txtDays.Text
    
                        'loop through all defined issues and display them
                        If EndByDate Then
                            While tempDate <= EndOn
                                'Response.Write(String.Format("Day {0}: ", tempDate.DayOfYear))
                                'Response.Write(String.Format("{0:d}<br>", tempDate))
                                issueset.AddIssue(cs, IssueSetID, tempDate, tempDate.DayOfYear)
                                tempDate = tempDate.AddDays(days)
                            End While
                        Else
                            i = 1
                            While i <= EndAfter
                                'Response.Write(String.Format("Day {0}: ", tempDate.DayOfYear))
                                'Response.Write(String.Format("{0}<br>", tempDate))
                                issueset.AddIssue(cs, IssueSetID, tempDate, tempDate.DayOfYear)
                                tempDate = tempDate.AddDays(days)
                                i += 1
                            End While
                        End If
                    Case "weekly"
                        'get the week frequency
                        Dim weeks As Integer = txtWeeks.Text
    
                        'get the days of the week that this is set for
                        Dim Monday As Boolean = chkWeekDays.Items(0).Selected
                        Dim Tuesday As Boolean = chkWeekDays.Items(1).Selected
                        Dim Wednesday As Boolean = chkWeekDays.Items(2).Selected
                        Dim Thursday As Boolean = chkWeekDays.Items(3).Selected
                        Dim Friday As Boolean = chkWeekDays.Items(4).Selected
                        Dim Saturday As Boolean = chkWeekDays.Items(5).Selected
                        Dim Sunday As Boolean = chkWeekDays.Items(6).Selected
    
                        'are we doing a weekly pattern based on the days of the week?
                        If Monday Or Tuesday Or Wednesday Or Thursday Or Friday Or Saturday Or Sunday Then
                            'loop through all defined issues and display them
                            If EndByDate Then
                                While tempDate <= EndOn
                                    tempDayOfWeek = tempDate
                                    Dim j As Integer
                                    For j = 0 To 6
    
                                        If Monday And (tempDate.AddDays(j).DayOfWeek = DayOfWeek.Monday) Then
                                            'Response.Write(String.Format("Week {0} {1}: ", DatePart("ww", tempDate.AddDays(j)), Format(tempDate.AddDays(j), "ddd")))
                                            'Response.Write(String.Format("{0}<br>", tempDate.AddDays(j)))
                                            issueset.AddIssue(cs, IssueSetID, tempDate.AddDays(j), Format(tempDate.AddDays(j), "ddd"))
                                            If tempDate.AddDays(j) >= EndOn Then Exit For
                                        End If
    
                                        If Tuesday And (tempDate.AddDays(j).DayOfWeek = DayOfWeek.Tuesday) Then
                                            'Response.Write(String.Format("Week {0} {1}: ", DatePart("ww", tempDate.AddDays(j)), Format(tempDate.AddDays(j), "ddd")))
                                            'Response.Write(String.Format("{0}<br>", tempDate.AddDays(j)))
                                            issueset.AddIssue(cs, IssueSetID, tempDate.AddDays(j), Format(tempDate.AddDays(j), "ddd"))
                                            tempDayOfWeek = tempDate.AddDays(j)
                                            If tempDate.AddDays(j) >= EndOn Then Exit For
                                        End If
    
                                        If Wednesday And (tempDate.AddDays(j).DayOfWeek = DayOfWeek.Wednesday) Then
                                            'Response.Write(String.Format("Week {0} {1}: ", DatePart("ww", tempDate.AddDays(j)), Format(tempDate.AddDays(j), "ddd")))
                                            'Response.Write(String.Format("{0}<br>", tempDate.AddDays(j)))
                                            issueset.AddIssue(cs, IssueSetID, tempDate.AddDays(j), Format(tempDate.AddDays(j), "ddd"))
                                            tempDayOfWeek = tempDate.AddDays(j)
                                            If tempDate.AddDays(j) >= EndOn Then Exit For
                                        End If
    
                                        If Thursday And (tempDate.AddDays(j).DayOfWeek = DayOfWeek.Thursday) Then
                                            'Response.Write(String.Format("Week {0} {1}: ", DatePart("ww", tempDate.AddDays(j)), Format(tempDate.AddDays(j), "ddd")))
                                            'Response.Write(String.Format("{0}<br>", tempDate.AddDays(j)))
                                            issueset.AddIssue(cs, IssueSetID, tempDate.AddDays(j), Format(tempDate.AddDays(j), "ddd"))
                                            tempDayOfWeek = tempDate.AddDays(j)
                                            If tempDate.AddDays(j) >= EndOn Then Exit For
                                        End If
    
                                        If Friday And (tempDate.AddDays(j).DayOfWeek = DayOfWeek.Friday) Then
                                            'Response.Write(String.Format("Week {0} {1}: ", DatePart("ww", tempDate.AddDays(j)), Format(tempDate.AddDays(j), "ddd")))
                                            'Response.Write(String.Format("{0}<br>", tempDate.AddDays(j)))
                                            issueset.AddIssue(cs, IssueSetID, tempDate.AddDays(j), Format(tempDate.AddDays(j), "ddd"))
                                            tempDayOfWeek = tempDate.AddDays(j)
                                            If tempDate.AddDays(j) >= EndOn Then Exit For
                                        End If
    
                                        If Saturday And (tempDate.AddDays(j).DayOfWeek = DayOfWeek.Saturday) Then
                                            'Response.Write(String.Format("Week {0} {1}: ", DatePart("ww", tempDate.AddDays(j)), Format(tempDate.AddDays(j), "ddd")))
                                            'Response.Write(String.Format("{0}<br>", tempDate.AddDays(j)))
                                            issueset.AddIssue(cs, IssueSetID, tempDate.AddDays(j), Format(tempDate.AddDays(j), "ddd"))
                                            tempDayOfWeek = tempDate.AddDays(j)
                                            If tempDate.AddDays(j) >= EndOn Then Exit For
                                        End If
    
                                        If Sunday And (tempDate.AddDays(j).DayOfWeek = DayOfWeek.Sunday) Then
                                            'Response.Write(String.Format("Week {0} {1}: ", DatePart("ww", tempDate.AddDays(j)), Format(tempDate.AddDays(j), "ddd")))
                                            'Response.Write(String.Format("{0}<br>", tempDate.AddDays(j)))
                                            issueset.AddIssue(cs, IssueSetID, tempDate.AddDays(j), Format(tempDate.AddDays(j), "ddd"))
                                            tempDayOfWeek = tempDate.AddDays(j)
                                            If tempDate.AddDays(j) >= EndOn Then Exit For
                                        End If
                                    Next
                                    tempDate = tempDate.AddDays(7 * weeks)
                                End While
                            Else
                                i = 1
                                While i <= EndAfter
                                    Dim j As Integer
                                    For j = 0 To 6
                                        If Monday And (tempDate.AddDays(j).DayOfWeek = DayOfWeek.Monday) Then
                                            'Response.Write(String.Format("Week {0} {1}: ", DatePart("ww", tempDate.AddDays(j)), Format(tempDate.AddDays(j), "ddd")))
                                            'Response.Write(String.Format("{0}<br>", tempDate.AddDays(j)))
                                            issueset.AddIssue(cs, IssueSetID, tempDate.AddDays(j), Format(tempDate.AddDays(j), "ddd"))
                                            i += 1
                                            If i > EndAfter Then Exit For
                                        End If
    
                                        If Tuesday And (tempDate.AddDays(j).DayOfWeek = DayOfWeek.Tuesday) Then
                                            'Response.Write(String.Format("Week {0} {1}: ", DatePart("ww", tempDate.AddDays(j)), Format(tempDate.AddDays(j), "ddd")))
                                            'Response.Write(String.Format("{0}<br>", tempDate.AddDays(j)))
                                            issueset.AddIssue(cs, IssueSetID, tempDate.AddDays(j), Format(tempDate.AddDays(j), "ddd"))
                                            i += 1
                                            If i > EndAfter Then Exit For
                                        End If
    
                                        If Wednesday And (tempDate.AddDays(j).DayOfWeek = DayOfWeek.Wednesday) Then
                                            'Response.Write(String.Format("Week {0} {1}: ", DatePart("ww", tempDate.AddDays(j)), Format(tempDate.AddDays(j), "ddd")))
                                            'Response.Write(String.Format("{0}<br>", tempDate.AddDays(j)))
                                            issueset.AddIssue(cs, IssueSetID, tempDate.AddDays(j), Format(tempDate.AddDays(j), "ddd"))
                                            i += 1
                                            If i > EndAfter Then Exit For
                                        End If
    
                                        If Thursday And (tempDate.AddDays(j).DayOfWeek = DayOfWeek.Thursday) Then
                                            'Response.Write(String.Format("Week {0} {1}: ", DatePart("ww", tempDate.AddDays(j)), Format(tempDate.AddDays(j), "ddd")))
                                            'Response.Write(String.Format("{0}<br>", tempDate.AddDays(j)))
                                            issueset.AddIssue(cs, IssueSetID, tempDate.AddDays(j), Format(tempDate.AddDays(j), "ddd"))
                                            i += 1
                                            If i > EndAfter Then Exit For
                                        End If
    
                                        If Friday And (tempDate.AddDays(j).DayOfWeek = DayOfWeek.Friday) Then
                                            'Response.Write(String.Format("Week {0} {1}: ", DatePart("ww", tempDate.AddDays(j)), Format(tempDate.AddDays(j), "ddd")))
                                            'Response.Write(String.Format("{0}<br>", tempDate.AddDays(j)))
                                            issueset.AddIssue(cs, IssueSetID, tempDate.AddDays(j), Format(tempDate.AddDays(j), "ddd"))
                                            i += 1
                                            If i > EndAfter Then Exit For
                                        End If
    
                                        If Saturday And (tempDate.AddDays(j).DayOfWeek = DayOfWeek.Saturday) Then
                                            'Response.Write(String.Format("Week {0} {1}: ", DatePart("ww", tempDate.AddDays(j)), Format(tempDate.AddDays(j), "ddd")))
                                            'Response.Write(String.Format("{0}<br>", tempDate.AddDays(j)))
                                            issueset.AddIssue(cs, IssueSetID, tempDate.AddDays(j), Format(tempDate.AddDays(j), "ddd"))
                                            i += 1
                                            If i > EndAfter Then Exit For
                                        End If
    
                                        If Sunday And (tempDate.AddDays(j).DayOfWeek = DayOfWeek.Sunday) Then
                                            'Response.Write(String.Format("Week {0} {1}: ", DatePart("ww", tempDate.AddDays(j)), Format(tempDate.AddDays(j), "ddd")))
                                            'Response.Write(String.Format("{0}<br>", tempDate.AddDays(j)))
                                            issueset.AddIssue(cs, IssueSetID, tempDate.AddDays(j), Format(tempDate.AddDays(j), "ddd"))
                                            i += 1
                                            If i > EndAfter Then Exit For
                                        End If
                                    Next
                                    tempDate = tempDate.AddDays(7 * weeks)
                                End While
                            End If
                        Else
                            'loop through all defined issues and display them
                            If EndByDate Then
                                While tempDate <= EndOn
                                    'Response.Write(String.Format("Week {0}: ", DatePart("ww", tempDate)))
                                    'Response.Write(String.Format("{0}<br>", tempDate))
                                    issueset.AddIssue(cs, IssueSetID, tempDate, DatePart("ww", tempDate))
                                    tempDate = tempDate.AddDays(7 * weeks)
                                End While
                            Else
                                i = 1
                                While i <= EndAfter
                                    'Response.Write(String.Format("Week {0}: ", DatePart("ww", tempDate)))
                                    'Response.Write(String.Format("{0}<br>", tempDate))
                                    issueset.AddIssue(cs, IssueSetID, tempDate, DatePart("ww", tempDate))
                                    tempDate = tempDate.AddDays(7 * weeks)
                                    i += 1
                                End While
                            End If
                        End If
                    Case "monthly"
                        'get the month frequency
                        Dim months As Integer = txtMonths.Text
    
                        'are we calculating by day of month?
                        If rdoMonthDay.Checked Then
                            'get the first date in the series        
                            If ddlMonthDay.SelectedValue = "last" Then
                                'loop through all defined issues and display them
                                If EndByDate Then
                                    While tempDate <= EndOn
                                        tempDate = LastDayOfMonth(tempDate)
                                        'Response.Write(String.Format("{0}: ", tempDate.ToString("MMM")))
                                        'Response.Write(String.Format("{0}<br>", tempDate))
                                        issueset.AddIssue(cs, IssueSetID, tempDate, tempDate.ToString("MMM"))
                                        tempDate = tempDate.AddMonths(months)
                                    End While
                                Else
                                    i = 1
                                    While i <= EndAfter
                                        tempDate = LastDayOfMonth(tempDate)
                                        'Response.Write(String.Format("{0}: ", tempDate.ToString("MMM")))
                                        'Response.Write(String.Format("{0}<br>", tempDate))
                                        issueset.AddIssue(cs, IssueSetID, tempDate, tempDate.ToString("MMM"))
                                        tempDate = tempDate.AddMonths(months)
                                        i += 1
                                    End While
                                End If
                            Else
                                If StartDate.Day > ddlMonthDay.SelectedValue Then
                                    StartDate = String.Format("{0}/{1}/{2}", Month(StartDate.AddMonths(1)), ddlMonthDay.SelectedValue, Year(StartDate.AddMonths(1)))
                                Else
                                    StartDate = String.Format("{0}/{1}/{2}", Month(StartDate), ddlMonthDay.SelectedValue, Year(StartDate))
                                End If
    
                                'loop through all defined issues and display them
                                If EndByDate Then
                                    While tempDate <= EndOn
                                        'Response.Write(String.Format("{0}: ", tempDate.ToString("MMM")))
                                        'Response.Write(String.Format("{0}<br>", tempDate))
                                        issueset.AddIssue(cs, IssueSetID, tempDate, tempDate.ToString("MMM"))
                                        tempDate = tempDate.AddMonths(months)
                                    End While
                                Else
                                    i = 1
                                    While i <= EndAfter
                                        'Response.Write(String.Format("{0}: ", tempDate.ToString("MMM")))
                                        'Response.Write(String.Format("{0}<br>", tempDate))
                                        issueset.AddIssue(cs, IssueSetID, tempDate, tempDate.ToString("MMM"))
                                        tempDate = tempDate.AddMonths(months)
                                        i += 1
                                    End While
                                End If
                            End If
                        ElseIf rdoMonthPart.Checked Then
                            'which day of the week are we lookin for
                            Dim DayOfWeek As System.DayOfWeek
                            Select Case ddlDayOfWeek.SelectedValue.ToLower
                                Case "monday"
                                    DayOfWeek = DayOfWeek.Monday
                                Case "tuesday"
                                    DayOfWeek = DayOfWeek.Tuesday
                                Case "wednesday"
                                    DayOfWeek = DayOfWeek.Wednesday
                                Case "thursday"
                                    DayOfWeek = DayOfWeek.Thursday
                                Case "friday"
                                    DayOfWeek = DayOfWeek.Friday
                                Case "saturday"
                                    DayOfWeek = DayOfWeek.Saturday
                                Case "sunday"
                                    DayOfWeek = DayOfWeek.Sunday
                            End Select
    
                            If ddlWeekofMonth.SelectedValue = "last" Then
                                'loop through all defined issues and display them
                                If EndByDate Then
                                    i = 0
                                    While tempDate <= EndOn
                                        tempDate = DayOfMonth(FirstDayOfMonth(tempDate).AddMonths(1), DayOfWeek, 1).AddDays(-7)
                                        'Response.Write(String.Format("{0}: ", tempDate.ToString("MMM")))
                                        'Response.Write(String.Format("{0}<br>", tempDate))
                                        issueset.AddIssue(cs, IssueSetID, tempDate, tempDate.ToString("MMM"))
                                        tempDate = tempDate.AddMonths(months)
                                    End While
                                Else
                                    i = 1
                                    While i <= EndAfter
                                        tempDate = DayOfMonth(FirstDayOfMonth(tempDate).AddMonths(1), DayOfWeek, 1).AddDays(-7)
                                        'Response.Write(String.Format("{0}: ", tempDate.ToString("MMM")))
                                        'Response.Write(String.Format("{0}<br>", tempDate))
                                        issueset.AddIssue(cs, IssueSetID, tempDate, tempDate.ToString("MMM"))
                                        tempDate = tempDate.AddMonths(months)
                                        i += 1
                                    End While
                                End If
                            Else
                                'loop through all defined issues and display them
                                If EndByDate Then
                                    i = 0
                                    While tempDate <= EndOn
                                        tempDate = DayOfMonth(FirstDayOfMonth(tempDate), DayOfWeek, ddlWeekofMonth.SelectedValue)
                                        'Response.Write(String.Format("{0}: ", tempDate.ToString("MMM")))
                                        'Response.Write(String.Format("{0}<br>", tempDate))
                                        issueset.AddIssue(cs, IssueSetID, tempDate, tempDate.ToString("MMM"))
                                        tempDate = tempDate.AddMonths(months)
                                    End While
                                Else
                                    i = 1
                                    While i <= EndAfter
                                        tempDate = DayOfMonth(FirstDayOfMonth(tempDate), DayOfWeek, ddlWeekofMonth.SelectedValue)
                                        'Response.Write(String.Format("{0}: ", tempDate.ToString("MMM")))
                                        'Response.Write(String.Format("{0}<br>", tempDate))
                                        issueset.AddIssue(cs, IssueSetID, tempDate, tempDate.ToString("MMM"))
                                        tempDate = tempDate.AddMonths(months)
                                        i += 1
                                    End While
                                End If
                            End If
                        End If
                    Case "yearly"
                        'get the year frequency
                        Dim years As Integer = txtYears.Text
    
                        'are we calculating by day of month in the year?
                        If rdoYearDay.Checked Then
                            'get the first date in the series        
                            If ddlYearMonthDay.SelectedValue = "last" Then
                                'get the start date, if it is after the day of the year selected for the frequency, jump to the next year
                                tempDate = New DateTime(Year(StartDate), ddlYearMonth.SelectedValue, 1)
                                tempDate = LastDayOfMonth(tempDate)
                                If StartDate > tempDate Then tempDate = tempDate.AddYears(1)
    
                                'loop through all defined issues and display them
                                If EndByDate Then
                                    While tempDate <= EndOn
                                        tempDate = LastDayOfMonth(tempDate)
                                        'Response.Write(String.Format("{0}: ", tempDate.Year))
                                        'Response.Write(String.Format("{0}<br>", tempDate))
                                        issueset.AddIssue(cs, IssueSetID, tempDate, tempDate.Year)
                                        tempDate = tempDate.AddYears(years)
                                    End While
                                Else
                                    i = 1
                                    While i <= EndAfter
                                        tempDate = LastDayOfMonth(tempDate)
                                        'Response.Write(String.Format("{0}: ", tempDate.Year))
                                        'Response.Write(String.Format("{0}<br>", tempDate))
                                        issueset.AddIssue(cs, IssueSetID, tempDate, tempDate.Year)
                                        tempDate = tempDate.AddYears(years)
                                        i += 1
                                    End While
                                End If
                            Else
                                'get the start date, if it is after the day of the year selected for the frequency, jump to the next year
                                tempDate = New DateTime(Year(StartDate), ddlYearMonth.SelectedValue, ddlYearMonthDay.SelectedValue)
                                If StartDate > tempDate Then tempDate = tempDate.AddYears(1)
    
                                'loop through all defined issues and display them
                                If EndByDate Then
                                    While tempDate <= EndOn
                                        'Response.Write(String.Format("{0}: ", tempDate.Year))
                                        'Response.Write(String.Format("{0}<br>", tempDate))
                                        issueset.AddIssue(cs, IssueSetID, tempDate, tempDate.Year)
                                        tempDate = tempDate.AddYears(years)
                                    End While
                                Else
                                    i = 1
                                    While i <= EndAfter
                                        'Response.Write(String.Format("{0}: ", tempDate.Year))
                                        'Response.Write(String.Format("{0}<br>", tempDate))
                                        issueset.AddIssue(cs, IssueSetID, tempDate, tempDate.Year)
                                        tempDate = tempDate.AddYears(years)
                                        i += 1
                                    End While
                                End If
                            End If
                        ElseIf rdoYearPart.Checked Then
                            'which day of the week are we lookin for
                            Dim DayOfWeek As System.DayOfWeek
                            Select Case ddlDayOfWeekYear.SelectedValue.ToLower
                                Case "monday"
                                    DayOfWeek = DayOfWeek.Monday
                                Case "tuesday"
                                    DayOfWeek = DayOfWeek.Tuesday
                                Case "wednesday"
                                    DayOfWeek = DayOfWeek.Wednesday
                                Case "thursday"
                                    DayOfWeek = DayOfWeek.Thursday
                                Case "friday"
                                    DayOfWeek = DayOfWeek.Friday
                                Case "saturday"
                                    DayOfWeek = DayOfWeek.Saturday
                                Case "sunday"
                                    DayOfWeek = DayOfWeek.Sunday
                            End Select
    
                            If ddlWeekOfMonthYear.SelectedValue = "last" Then
                                'get the first selected day of the next month
                                tempDate = New DateTime(Year(StartDate), ddlMonthOfYear.SelectedValue, 1).AddMonths(1)
                                'get the day from a week before, last of that day for the month
                                tempDate = tempDate.AddDays(-7)
                                If StartDate > tempDate Then tempDate = tempDate.AddYears(1)
    
                                'loop through all defined issues and display them
                                If EndByDate Then
                                    i = 0
                                    While tempDate <= EndOn
                                        tempDate = DayOfMonth(FirstDayOfMonth(tempDate).AddMonths(1), DayOfWeek, 1).AddDays(-7)
                                        'Response.Write(String.Format("{0}: ", tempDate.Year))
                                        'Response.Write(String.Format("{0}<br>", tempDate))
                                        issueset.AddIssue(cs, IssueSetID, tempDate, tempDate.Year)
                                        tempDate = tempDate.AddYears(years)
                                    End While
                                Else
                                    i = 1
                                    While i <= EndAfter
                                        tempDate = DayOfMonth(FirstDayOfMonth(tempDate).AddMonths(1), DayOfWeek, 1).AddDays(-7)
                                        'Response.Write(String.Format("{0}: ", tempDate.Year))
                                        'Response.Write(String.Format("{0}<br>", tempDate))
                                        issueset.AddIssue(cs, IssueSetID, tempDate, tempDate.Year)
                                        tempDate = tempDate.AddYears(years)
                                        i += 1
                                    End While
                                End If
                            Else
                                tempDate = New DateTime(Year(StartDate), ddlMonthOfYear.SelectedValue, 1)
                                tempDate = DayOfMonth(tempDate, DayOfWeek, ddlWeekOfMonthYear.SelectedValue)
                                If StartDate > tempDate Then tempDate = tempDate.AddYears(1)
    
                                'loop through all defined issues and display them
                                If EndByDate Then
                                    i = 0
                                    While tempDate <= EndOn
                                        tempDate = DayOfMonth(FirstDayOfMonth(tempDate), DayOfWeek, ddlWeekOfMonthYear.SelectedValue)
                                        'Response.Write(String.Format("{0}: ", tempDate.Year))
                                        'Response.Write(String.Format("{0}<br>", tempDate))
                                        issueset.AddIssue(cs, IssueSetID, tempDate, tempDate.Year)
                                        tempDate = tempDate.AddYears(years)
                                    End While
                                Else
                                    i = 1
                                    While i <= EndAfter
                                        tempDate = DayOfMonth(FirstDayOfMonth(tempDate), DayOfWeek, ddlWeekOfMonthYear.SelectedValue)
                                        'Response.Write(String.Format("{0}: ", tempDate.Year))
                                        'Response.Write(String.Format("{0}<br>", tempDate))
                                        issueset.AddIssue(cs, IssueSetID, tempDate, tempDate.Year)
                                        tempDate = tempDate.AddYears(years)
                                        i += 1
                                    End While
                                End If
                            End If
                        End If
                End Select
    
                'If PubID = -1 Then
                '    'go back to the list of issue sets
                '    Response.Redirect("/intranet/aspnet/issues/IssueSetList.aspx")
                'Else
                '    'go back to the list of issues for this issue set
                '    Response.Redirect("/intranet/aspnet/issues/IssueList.aspx?PubID=" & PubID)
                'End If
                Ext.Msg.Alert("Commited", "data saved successfully.").Show()
            Else
                Ext.Msg.Alert("Error", "Schedule details are not saved." & txtName.Text & "  is already exists. Please enter another name.").Show()
    
            End If
        End Sub
    
        Public Function LastDayOfMonth(ByVal tempDate As DateTime) As DateTime
            Return DateAdd(DateInterval.Second, -3, DateAdd(DateInterval.Month, DateDiff(DateInterval.Month, Date.MinValue, tempDate) + 1, Date.MinValue))
        End Function
    
        Public Function FirstDayOfMonth(ByVal tempDate As DateTime) As DateTime
            Return DateAdd(DateInterval.Month, DateDiff(DateInterval.Month, Date.MinValue, tempDate), Date.MinValue)
        End Function
    
        Private Function DayOfMonth(ByVal firstDayOfMonth As DateTime, ByVal day As DayOfWeek, ByVal iteration As Integer) As DateTime
            Return DateAdd(DateInterval.Day, (((day + 7) - firstDayOfMonth.DayOfWeek) Mod 7) + ((iteration - 1) * 7), firstDayOfMonth)
        End Function
    
        Private Sub btnCancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCancel.Click
            'Dim IssueSetID As Integer = -1
            'If Not Request.QueryString("IssueSetID") = Nothing Then IssueSetID = Request.QueryString("IssueSetID")
            Dim PubID As Integer = -1
            If Not Request.QueryString("PubID") = Nothing Then PubID = Request.QueryString("PubID")
    
            'If PubID = -1 Then
            '    'go back to the list of issue sets
            '    Response.Redirect("/intranet/aspnet/issues/IssueSetList.aspx")
            'Else
            '    'go back to the list of issues for this issue set
            '    Response.Redirect("/intranet/aspnet/issues/IssueList.aspx?PubID=" & PubID)
            'End If
        End Sub
    
    
        <AjaxMethod(Namespace:="Wizard")> _
        Public Sub AfterEdit(ByVal ID As Integer, ByVal field As String, ByVal oldvalue As String, ByVal newVal As String)
    
            Dim objIssueset As New IssueSet()
            If (Not (objIssueset.CheckScheduleNameExists(newVal))) Then
    
    
    
                ScriptManager1.AddScript("#{GridPanel1}.save();")
                Ext.Msg.Alert("Commited", "data updated successfully.").Show()
            Else
                Ext.Msg.Alert("Error", newVal & "  is already exists. Please enter another name.").Show()
    
            End If
        End Sub
    
    
        Protected Sub Command(ByVal sender As Object, ByVal e As AjaxEventArgs)
    
            Dim objIssueSet As New IssueSet()
            punName.Html = Convert.ToString(e.ExtraParams("name"))
    
            'storeIsuueDetails.DataSource = objIssueSet.GetIssueSetDetails(Convert.ToString(e.ExtraParams("id")))
            'storeIsuueDetails.DataBind()
            ViewState("issuesetId") = Convert.ToString(e.ExtraParams("id"))
            storeIsuueDetails_RefreshData(Nothing, Nothing)
            issueDetailsDatasource.DataBind()
            winIssueDetails.Show()
        End Sub
    
        Protected Sub issueDetailsDatasource_Selecting(ByVal sender As Object, ByVal e As SqlDataSourceSelectingEventArgs)
    
            ' e.Command.Parameters("@issueSetId").Value = Convert.ToString(ViewState("issuesetId"))
            'Ext.Msg.Alert("asd", Convert.ToString(ViewState("issuesetId"))).Show()
    
            'e.Command.Parameters("@issueSetId").Value = Convert.ToString(ViewState("issuesetId"))
            'issueDetailsDatasource.SelectParameters.Add("issueSetId", )
            'issueDetailsDatasource.Select(DataSourceSelectArguments.Empty)
            'issueDetailsDatasource.SelectParameters(0). = Convert.ToString(ViewState("issuesetId"))
    
        End Sub
        'Public Delegate Sub SqlDataSourceSelectingEventHandler(ByVal sender As Object, ByVal e As SqlDataSourceSelectingEventArgs)
    
        'Dim instance As New SqlDataSourceSelectingEventHandler(AddressOf issueDetailsDatasource_Selecting)
    
    
        Protected Sub storeIsuueDetails_RefreshData(ByVal sender As Object, ByVal e As StoreRefreshDataEventArgs)
    
            issueDetailsDatasource.SelectParameters("issueSetId").DefaultValue = Convert.ToString(ViewState("issuesetId"))
            storeIsuueDetails.DataBind()
    
        End Sub
    End Class
    Attached Thumbnails Click image for larger version. 

Name:	1.jpg 
Views:	196 
Size:	91.5 KB 
ID:	2766   Click image for larger version. 

Name:	2.jpg 
Views:	189 
Size:	89.3 KB 
ID:	2767  
    Attached Files
  2. #2
    Hi,

    As far as I know you can set select parameters within Selecting event.

    Here I demonstrated how it can be done with ObjectDataSource. I believe there will be the same situation with SqlDataSource.

    Please note that here is a fake scenario.

    Example Page
    <%@ Page Language="C#" %>
    
    <%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
    
    <script runat="server">
        protected void DataBind(object sender, DirectEventArgs e)
        {
            Store1.DataBind();
        }
    
        void ObjectDataSource1_Selecting(object sender, ObjectDataSourceSelectingEventArgs e)
        {
            e.InputParameters["id"] = HiddenId.Value ?? "";
        }
    </script>
    
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title>Ext.Net Example</title>
    </head>
    <body>
        <form runat="server">
            <ext:ResourceManager runat="server" />
            <ext:Hidden ID="HiddenId" runat="server" />
            <asp:ObjectDataSource 
                ID="ObjectDataSource1" 
                runat="server" 
                SelectMethod="GetAll"
                TypeName="Test" 
                OnSelecting="ObjectDataSource1_Selecting">
                <SelectParameters>
                    <asp:Parameter Name="id" Type="String" />
                </SelectParameters>
            </asp:ObjectDataSource>
            <ext:GridPanel ID="GridPanel1" runat="server" AutoHeight="true">
                <Store>
                    <ext:Store ID="Store1" runat="server" DataSourceID="ObjectDataSource1">
                        <Reader>
                            <ext:ArrayReader IDProperty="id">
                                <Fields>
                                    <ext:RecordField Name="id" />
                                    <ext:RecordField Name="test" />
                                </Fields>
                            </ext:ArrayReader>
                        </Reader>
                    </ext:Store>
                </Store>
                <ColumnModel runat="server">
                    <Columns>
                        <ext:Column Header="Id" DataIndex="id" />
                        <ext:Column Header="Test" DataIndex="test" />
                    </Columns>
                </ColumnModel>
            </ext:GridPanel>
            <ext:Button runat="server" Text="Retrieve only one record">
                <DirectEvents>
                    <Click OnEvent="DataBind" Before="HiddenId.setValue('one_')" />
                </DirectEvents>
            </ext:Button>
            <ext:Button runat="server" Text="Retrieve all">
                <DirectEvents>
                    <Click OnEvent="DataBind" Before="HiddenId.setValue('')" />
                </DirectEvents>
            </ext:Button>
        </form>
    </body>
    </html>
    Class Test
    public class Test
    {
        public static object[] GetAll(string id)
        {
            if (string.IsNullOrEmpty(id))
            {
                return new object[] 
                { 
                    new object[] { id + "1", "test1" },
                    new object[] { id + "2", "test2" },
                    new object[] { id + "3", "test3" }
                };
            }
            else
            {
                return new object[] 
                { 
                    new object[] { id + "1", "test1" },
                };
            }
        }
    }
  3. #3
    I believe there will be the same situation with SqlDataSource.
    You're right Daniil, SQLDataSource has a corrosponding 'Selecting' event, I've used it in the way illustrated outside of an Ext environment to reference parameters.

    Infact I believe it might be the only way you can programmatically set the value of parameters for data sources defined in aspx/ascx pages (I seem to remember having issues setting them in codebehind without using said event)
  4. #4
    Yes, I also can't see any other way to set these parameters.
  5. #5
    Sorry for digging up an old thread but here is an example of slightly different approach using the filterexpression of the sqldatasource and a hidden field for the passing parameter into the sqldatasource. It may help someone searching the thread topic.

                <ext:GridPanel ID="ProjectGridPanel" runat="server" Title="Recent Projects" StoreID="ProjectStore">
                    <ColumnModel ID="ProjectColumnModel" runat="server">
                        <Columns>
                            <ext:Column Header="ID" Width="30" DataIndex="ID_Project" Tooltip="Project ID" Editable="False" />
                            <ext:Column Header="Project Name" Width="300" DataIndex="NM_Project" Tooltip="Project Name" />
                        </Columns>
                    </ColumnModel>
                    <SelectionModel>
                        <ext:RowSelectionModel ID="ProjectRowSelectionModel" runat="server">
                            <Listeners>
                                <RowSelect Handler="#{ProjectGridProjectIdValue}.setValue(#{ProjectGridPanel}.store.getAt(#{ProjectGridPanel}.store.indexOf(#{ProjectGridPanel}.getSelectionModel().getSelected())).get('ID_Project'));#{ProjectDescriptionStore}.reload();"  Buffer="250" />
                            </Listeners>
                        </ext:RowSelectionModel>
                    </SelectionModel>
                </ext:GridPanel>
    
                <ext:Hidden ID="ProjectGridProjectIdValue" runat="server" Text="0" />
    
                <asp:SqlDataSource ID="ProjectDescriptionSqlDataSource" runat="server" 
                        ConnectionString="<%$ ConnectionStrings:Test_ApplicationConnectionString %>" 
                        SelectCommand="
            SELECT 
                ID_ProjectDescription, ID_Project, DESC_Project
            FROM 
                [ProjectDescription]
                " 
                    FilterExpression="ID_Project='{0}'" >
                    <FilterParameters>
                        <asp:ControlParameter Name="ID_Project" ControlId="ProjectGridProjectIdValue" DefaultValue="0" />
                    </FilterParameters>
                </asp:SqlDataSource>
    
                <ext:Store ID="ProjectDescriptionStore" runat="server" DataSourceID="ProjectDescriptionSqlDataSource">
                    <Reader>
                        <ext:JsonReader IDProperty="ID_ProjectDescription">
                            <Fields>
                                <ext:RecordField Name="ID_ProjectDescription" SortType="AsInt" />                            
                                <ext:RecordField Name="ID_Project" SortType="AsInt" />                            
                                <ext:RecordField Name="DESC_Project" SortType="AsText" />                            
                            </Fields>
                        </ext:JsonReader>
                    </Reader>
                </ext:Store>
    
                <ext:GridPanel ID="ProjectDescriptionGridPanel" runat="server" Title="Project Descriptions" StoreID="ProjectDescriptionStore">
                    <ColumnModel ID="ProjectDescriptionColumnModel" runat="server">
                        <Columns>
                            <ext:Column Header="ID" Width="30" DataIndex="ID_ProjectDescription" Tooltip="Project Description ID" Editable="False" />
                            <ext:Column Header="Project ID" Width="30" DataIndex="ID_Project" Tooltip="Project ID" />
                            <ext:Column Header="Project Description" Width="300" DataIndex="DESC_Project" Tooltip="Project Description" />
                        </Columns>
                    </ColumnModel>
                </ext:GridPanel>
  6. #6
    @hc.dev, thanks for sharing!

Similar Threads

  1. Form_Details Example SqlDataSource help
    By preussmd in forum 1.x Help
    Replies: 1
    Last Post: Oct 23, 2012, 8:36 PM
  2. SQLDataSource Examples
    By preussmd in forum Open Discussions
    Replies: 2
    Last Post: Nov 07, 2010, 8:29 PM
  3. for SqlDataSource
    By lindgrenm in forum 1.x Help
    Replies: 0
    Last Post: Sep 23, 2009, 5:47 PM
  4. ComboBox with SqlDataSource
    By gargamel4670 in forum 1.x Help
    Replies: 10
    Last Post: Mar 04, 2009, 4:02 PM

Tags for this Thread

Posting Permissions