Naheed_2 0 Newbie Poster

Hi,

I have the following html code I have for a task manager.

<%@ Page Title="" Language="C#" MasterPageFile="~/Site02.Master" AutoEventWireup="true" CodeBehind="Tasks.aspx.cs" Inherits="DMS.Tasks" %>
<%@ Register assembly="Telerik.Web.UI" namespace="Telerik.Web.UI" tagprefix="telerik" %>

<asp:Content ID="Content1" ContentPlaceHolderID="MainContent" runat="server">
    <telerik:RadAjaxPanel ID="RadAjaxPanel1" runat="server">

        <div class="row-fluid sortable">

            <asp:Button runat="server" ID="btnAddTask" CssClass="btn btn-success btn-toolbar" Text="Create Task" OnClick="btnAddTask_Click" />
            <asp:Button runat="server" ID="btnEditTask" CssClass="btn btn-warning btn-toolbar" Text="Edit Task Status" OnClick="btnEditTask_Click" />
            <asp:Button runat="server" ID="btnDay" CssClass="btn  btn-toolbar" Text="Day" OnClick="btnDay_Click" />
            <asp:Button runat="server" ID="btnMonth" CssClass="btn  btn-toolbar" Text="Month" OnClick="btnMonth_Click" />
            <asp:Button runat="server" ID="btnYear" CssClass="btn  btn-toolbar" Text="Year" OnClick="btnYear_Click" />
            <asp:Button runat="server" ID="btnFilter" CssClass="btn btn-primary btn-toolbar" Text="Filter" OnClick="btnFilter_Click" />
             <telerik:RadWindow RenderMode="Lightweight" runat="server" ID="RadWindow1" RestrictionZoneID="ContentTemplateZone" AutoSize="true"
        Modal="true" Title="Search Criteria"  Width="600px" Height="450px" Animation="FlyIn" CenterIfModal="true" Visible="true" Skin="Bootstrap" Behaviors="Close" >
        <ContentTemplate>

            <p class="contText">
                <asp:Label runat="server" ID="Label1" Text="Select Date"></asp:Label>
            </p>

            <p class="contText">
                <telerik:RadCalendar ID="RadCalendar1" runat="server" EnableKeyboardNavigation="True" EnableMultiSelect="False"  EnableWeekends="True" FastNavigationNextText="&amp;lt;&amp;lt;" SelectedDate="" Skin="Bootstrap">
                    <SpecialDays>
                        <telerik:RadCalendarDay Date="" Repeatable="Today">
                            <ItemStyle CssClass="rcToday" />
                        </telerik:RadCalendarDay>
                    </SpecialDays>
                    <WeekendDayStyle CssClass="rcWeekend" />
                    <CalendarTableStyle CssClass="rcMainTable" />
                    <OtherMonthDayStyle CssClass="rcOtherMonth" />
                    <OutOfRangeDayStyle CssClass="rcOutOfRange" />
                    <DisabledDayStyle CssClass="rcDisabled" />
                    <SelectedDayStyle CssClass="rcSelected" />
                    <DayOverStyle CssClass="rcHover" />
                    <FastNavigationStyle CssClass="RadCalendarMonthView RadCalendarMonthView_Bootstrap" />
                    <ViewSelectorStyle CssClass="rcViewSel" />
                </telerik:RadCalendar>
            </p>

                    <div class="contButton">
                        <asp:Button ID="Button2" runat="server" OnClick="Button2_Click" Text="Search" CssClass="btn btn-primary" />
                    </div>

        </ContentTemplate>
    </telerik:RadWindow>

            <telerik:RadWindow RenderMode="Lightweight" runat="server" ID="RadWindow2" RestrictionZoneID="ContentTemplateZone" AutoSize="true"
        Modal="true" Title="Search Criteria"  Width="600px" Height="450px" Animation="FlyIn" CenterIfModal="true" Visible="true" Skin="Bootstrap" Behaviors="Close" >
        <ContentTemplate>

            <p class="contText">
                <asp:Label runat="server" ID="Label2" Text="Select Month & Year"></asp:Label>
            </p>

            <p class="contText">
                <telerik:RadMonthYearPicker ID="RadMonthYearPicker1" runat="server" Skin="Bootstrap" ></telerik:RadMonthYearPicker>
                </p>
                <div class="contButton">
                    <asp:Button ID="Button3" runat="server" CssClass="btn btn-primary" OnClick="Button3_Click" Text="Search" />
                </div>
            </p>

        </ContentTemplate>
    </telerik:RadWindow>

                        <telerik:RadWindow RenderMode="Lightweight" runat="server" ID="RadWindow3" RestrictionZoneID="ContentTemplateZone" AutoSize="true"
        Modal="true" Title="Search Criteria"  Width="600px" Height="450px" Animation="Fade" CenterIfModal="true" Visible="true" Skin="Bootstrap" Behaviors="Close" >
        <ContentTemplate>

            <p class="contText">
                <asp:Label runat="server" ID="Label4" Text="Select Year"></asp:Label>
            </p>

            <p class="contText">
                <asp:DropDownList ID="ddlYear" runat="server">
                </asp:DropDownList>
            </p>

                    <div class="contButton">
                        <asp:Button ID="Button4" runat="server" OnClick="Button4_Click" Text="Search" CssClass="btn btn-primary" />
                    </div>

        </ContentTemplate>
    </telerik:RadWindow>

            <telerik:RadWindow RenderMode="Auto" runat="server" ID="RadWindow4" RestrictionZoneID="ContentTemplateZone" 
        Modal="true" Title="Create Task"  Width="600px" Height="450px" Animation="Fade" CenterIfModal="true" Visible="true" Skin="Bootstrap" Behaviors="Close" >
        <ContentTemplate>
            <div class="row-fluid sortable">
                <div class="span5">
                    <h2>Subject:</h2><span><asp:TextBox ID="txtSubject" runat="server" MaxLength="100"></asp:TextBox></span>
                    <h2>Task Details:</h2><span><asp:TextBox ID="txtDetails" runat="server" MaxLength="500" TextMode="MultiLine"></asp:TextBox></span>
                    <h2>Start Date:</h2><span>
                        <telerik:RadDatePicker ID="RadDatePicker1" runat="server"></telerik:RadDatePicker>
                    </span>
                    <h2>End Date:</h2><span>
                        <telerik:RadDatePicker ID="RadDatePicker2" runat="server"></telerik:RadDatePicker>
                    </span>
                    <br />
                    <br />
                </div>
                <div class="span5">
                    <h2>Assignees</h2>

                     <telerik:RadGrid ID="RadGrid1" runat="server" CellSpacing="0" 
                    DataSourceID="SqlDataSource2" GridLines="None" Height="128px" 
                    Width="400px" Skin="Bootstrap" >
<FilterMenu EnableImageSprites="False"></FilterMenu>

<ClientSettings>
<Selecting CellSelectionMode="None" AllowRowSelect="True"></Selecting>
    <Scrolling AllowScroll="True" UseStaticHeaders="True" />
</ClientSettings>

<MasterTableView AutoGenerateColumns="False" DataSourceID="SqlDataSource2">
<CommandItemSettings ExportToPdfText="Export to PDF"></CommandItemSettings>

<RowIndicatorColumn Visible="True" FilterControlAltText="Filter RowIndicator column">
<HeaderStyle Width="20px"></HeaderStyle>
</RowIndicatorColumn>

<ExpandCollapseColumn Visible="True" FilterControlAltText="Filter ExpandColumn column">
<HeaderStyle Width="20px"></HeaderStyle>
</ExpandCollapseColumn>

    <Columns>
    <telerik:GridTemplateColumn HeaderText="Select:">
    <ItemTemplate>
    <asp:CheckBox  ID="chkSelect" Checked="false" Enabled ="true" runat="server" Width = "50px" />
    </ItemTemplate>
        <HeaderStyle Width="100px" />

    </telerik:GridTemplateColumn>

        <telerik:GridBoundColumn DataField="DiskUserID" 
            FilterControlAltText="Filter DiskUserID column" HeaderText="User ID" 
            SortExpression="DiskUserID" UniqueName="DiskUserID" >
            <FooterStyle Width="50px" />
            <HeaderStyle Width="100px" />
        </telerik:GridBoundColumn>
        <telerik:GridBoundColumn DataField="UserName" 
            FilterControlAltText="Filter UserName column" HeaderText="Name" ReadOnly="True" 
            SortExpression="UserName" UniqueName="UserName">
        </telerik:GridBoundColumn>
    </Columns>

<EditFormSettings>
<EditColumn FilterControlAltText="Filter EditCommandColumn column"></EditColumn>
</EditFormSettings>
</MasterTableView>
                </telerik:RadGrid>

                <asp:SqlDataSource ID="SqlDataSource2" runat="server" 
                    ConnectionString="<%$ ConnectionStrings:cloud %>" 

                    SelectCommand="SELECT [DiskUserFirstName] + [DiskUserLastName] as UserName, [DiskUserID] FROM [DMS_DiskUserMaster] 
WHERE (([DiskAccountID] = @DiskAccountID) AND ([DiskUserStatus] = 'Active') and (DiskUserID &lt;&gt; @DiskUserID ))">
                    <SelectParameters>
                        <asp:SessionParameter Name="DiskAccountID" 
                            SessionField="Application Disk Account ID" Type="String" />
                        <asp:SessionParameter Name="DiskUserID" SessionField="Application Disk User ID" />
                    </SelectParameters>
                </asp:SqlDataSource>
                </div>
            </div>

                    <div class="contButton">

                        <asp:Button ID="Button5" runat="server" OnClick="Button5_Click" Text="Save Task" CssClass="btn btn-warning" />
                        <asp:Button ID="Button6" runat="server" OnClick="Button6_Click" Text="Cancel" CssClass="btn btn-primary" />
                    </div>

        </ContentTemplate>
    </telerik:RadWindow>

              <telerik:RadCodeBlock runat="server" ID="rdbScripts">
        <script type="text/javascript">
        $modalWindowDemo.modalWindowID = "<%=RadWindow1.ClientID %>";
        </script>
        <script type="text/javascript">
        $modalWindowDemo.modalWindowID = "<%=RadWindow2.ClientID %>";
        </script>
        <script type="text/javascript">
        $modalWindowDemo.modalWindowID = "<%=RadWindow3.ClientID %>";
        </script>
        <script type="text/javascript">
        $modalWindowDemo.modalWindowID = "<%=RadWindow4.ClientID %>";
        </script>
                </telerik:RadCodeBlock>
        </div>

        <div class="row-fluid sortable" id="TaskDivs" runat="server">

            <div class="span5" runat="server" id="TaskSpan1">

            </div>
            <div class="span5" runat="server" id="TaskSpan2">

            </div>

        </div>

    </telerik:RadAjaxPanel>
</asp:Content>

and the following code behind that dynamically creates divs with data in them from a database.

protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["Application Disk Account ID"] == null)
            {
                Response.Redirect("Default.aspx");
            }
            if (!IsPostBack)
            {
                Create_Div1();
            }
        }

        protected void Create_Div1()
        {
            string strdiv = string.Empty;
            cldDbTransactions clstxn = new cldDbTransactions();
            string getdata;
            getdata="select TM.Task_Subject,TM.Task_Parent_ID,TM.Task_Details,DU.DisplayName,TM.Task_Status, ";
            getdata = getdata + "convert(Varchar(15),TM.Task_Start_Date,106) as TaskDate, datediff(day,TM.Task_Start_Date,getdate()) ";
            getdata = getdata + "from DMS_Task_Manager TM, DMS_DiskUserMaster DU where TM.Assignor_User_ID = DU.DiskUserID ";
            getdata = getdata + "and TM.Assignor_User_ID = '" + Session["Application Disk User ID"].ToString() + "' ";
            getdata = getdata + "and TM.Assignor_User_ID = TM.Assignee_User_ID";
            clstxn.SearchRows(getdata);
            strdiv = "<div class ='priority high' runat='server' id='Taskset'><span>Assigned By Me</span></div>";
            if(clstxn.SearchReturnedRows()==true)
            {
                for (int i = 0; i < clstxn.DtSet.Tables[0].Rows.Count; i++)
                {
                    strdiv = strdiv + "<div class='task high' runat='server'>";
                    strdiv = strdiv + "<div class='desc'>";
                    strdiv = strdiv + "<div class='title'>" + clstxn.DtSet.Tables[0].Rows[i][0].ToString() + "</div>";
                    strdiv = strdiv + "<div>ID: "+ clstxn.DtSet.Tables[0].Rows[i][1].ToString() + "</div>";
                    strdiv = strdiv + "<div>Description: "+ clstxn.DtSet.Tables[0].Rows[i][2].ToString() + "</div>";
                    strdiv = strdiv + "<div>Assigned By: "+ clstxn.DtSet.Tables[0].Rows[i][3].ToString() + "</div>";
                    strdiv = strdiv + "<div>Status: " + clstxn.DtSet.Tables[0].Rows[i][4].ToString() + "</div>";
                    strdiv = strdiv + "</div>";
                    strdiv = strdiv + "<div class='time'>";
                    strdiv = strdiv + "<div class='date'>"+ clstxn.DtSet.Tables[0].Rows[i][5].ToString() +"</div>";
                    strdiv = strdiv + "<div>" + clstxn.DtSet.Tables[0].Rows[i][6].ToString() + "day(s)</div>";
                    strdiv = strdiv + "</div>";
                    strdiv = strdiv + "</div>";
                }
                TaskSpan1.InnerHtml = strdiv;
            }
            else
            {
                strdiv = strdiv + "<div>No Tasks Available</div>";
                TaskSpan1.InnerHtml = strdiv;
            }
        }

I want to add a button inside each div that will then be used to mark the task as closed or reopened in the DB.

Please help. I also need to know how to then access the newly created buttons from code behind.

Thanks in advance for the help.

Naheed.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.21 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.