Issue with Telerik RadListView SelectIndex

3 posts, 0 answers
  1. xboxown
    xboxown avatar
    2 posts
    Member since:
    Nov 2011

    Posted 02 May 2013 Link to this post

      Hey,



    My issue is with ListView, I have the insert function working in the Telerik radlistview, but the delete and update it is not working because I need to get the homeworkID from each list. I do not know how to get the homeworkID or selectedindex. if you guys can help me on this...I woudl be so much appreciate it. I have the URL link where you can download the source code: http://www.mediafire.com/download.php?xj3ll2qjajglyrf.

    For people who do not want to download the source code and want to it see it here I have pasted the code in here as well:

    <%@ Page Title="" Language="VB" MasterPageFile="~/Admin.master" AutoEventWireup="false" CodeFile="EditAssignHomework.aspx.vb" Inherits="EditAssignHomework" %>
    <%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
    <%@ Register TagPrefix="telerik" Namespace="Telerik.Web.UI" Assembly="Telerik.Web.UI" %>
     
    <asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
    </asp:Content>
    <asp:Content ID="Content2" ContentPlaceHolderID="MainContent" Runat="Server">
        <asp:ScriptManager runat="server" ID="scriptmanager1"></asp:ScriptManager>
         <telerik:RadFormDecorator runat="server" ID="QsfFromDecorator" DecoratedControls="All" EnableRoundedCorners="true" />
                  <div>
                      <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
                <AjaxSettings>
                    <telerik:AjaxSetting AjaxControlID="ListViewPanel1">
                        <UpdatedControls>
                            <telerik:AjaxUpdatedControl ControlID="ListViewPanel1" LoadingPanelID="RadAjaxLoadingPanel1">
                            </telerik:AjaxUpdatedControl>
                        </UpdatedControls>
                    </telerik:AjaxSetting>
                    <telerik:AjaxSetting AjaxControlID="RadListView1">
                        <UpdatedControls>
                            <telerik:AjaxUpdatedControl ControlID="lblhomeworkID" LoadingPanelID="RadAjaxLoadingPanel1">
                            </telerik:AjaxUpdatedControl>
                            <telerik:AjaxUpdatedControl ControlID="RadListView1" LoadingPanelID="RadAjaxLoadingPanel1" />
                        </UpdatedControls>
                    </telerik:AjaxSetting>
                        <telerik:AjaxSetting AjaxControlID="RadListView2">
                        <UpdatedControls>
                            <telerik:AjaxUpdatedControl ControlID="lblhomeworkID" LoadingPanelID="RadAjaxLoadingPanel1">
                            </telerik:AjaxUpdatedControl>
                            <telerik:AjaxUpdatedControl ControlID="RadListView2" LoadingPanelID="RadAjaxLoadingPanel1" />
                        </UpdatedControls>
                    </telerik:AjaxSetting>
                    <telerik:AjaxSetting AjaxControlID="CheckBoxList1">
                        <UpdatedControls>
                            <telerik:AjaxUpdatedControl ControlID="CheckBoxList1"></telerik:AjaxUpdatedControl>
                            <telerik:AjaxUpdatedControl ControlID="ListViewPanel1" LoadingPanelID="RadAjaxLoadingPanel1">
                            </telerik:AjaxUpdatedControl>
                        </UpdatedControls>
                    </telerik:AjaxSetting>
                </AjaxSettings>
                <ClientEvents OnRequestStart="RequestStart"></ClientEvents>
            </telerik:RadAjaxManager>
            <telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" runat="server">
            </telerik:RadAjaxLoadingPanel>
            <telerik:RadCodeBlock ID="RadCodeBlock1" runat="server">
                <script type="text/javascript">
                    function RequestStart(sender, eventArgs) {
                        //disable ajax on update/insert operation to upload the image
                        if ((eventArgs.get_eventTarget().indexOf("Update") > -1) || (eventArgs.get_eventTarget().indexOf("PerformInsert") > -1)) {
                            eventArgs.set_enableAjax(false);
                        }
                    }
                </script>
            </telerik:RadCodeBlock>
             
                  </div>
      
         <table id="Table1" runat="server" width="600px" >
            <tr>
               <td>
                  <asp:Label ID="Label1" runat="server" Text="List of available students:"></asp:Label>
               </td>
               <td>
                    <telerik:RadDropDownList runat="server" ID="lstStudentNames"  AutoPostBack="true" DefaultMessage="Select a record" DataValueField="UserID" DataTextField="FullName" DataSourceID="SqlDataSource1" OnItemDataBound="lstStudentNames_ItemDataBound" OnItemSelected="lstStudentNames_ItemSelected" OnSelectedIndexChanged="lstStudentNames_SelectedIndexChanged" Width="300px"></telerik:RadDropDownList>
               </td>
               </tr>
      
     
            <tr>
               <td>
                  
                   <table>
                      <tr>
                         <td>
                            <h3>Assignment(s) for student(s) configuration panel</h3>
                            <asp:Panel runat="server" ID="ListViewPanel1">
                                <telerik:RadListView ID="RadListView1" DataSourceID="SqlDataSource2" runat="server" OnSelectedIndexChanged="RadListView1_SelectedIndexChanged" ItemPlaceholderID="AssignmentsContainer" DataKeyNames="UserID" AllowPaging="true" OnItemCommand="RadListView1_ItemCommand">
                                    <LayoutTemplate>
                                        <fieldset id="FieldSet1" style="max-width: 946px;">
                                        <legend>Homeworks</legend>
                                        <table cellpadding="0" cellspacing="0" width="100%">
                                            <tr>
                                                <td>                                           
                                                    <telerik:RadDataPager runat="server" id="RadDataPager1" PageControlID="RadListView1" PageSize="2" CssClass="paperStyle">
                                                        <Fields>
                                                           <telerik:RadDataPagerButtonField FieldType="FirstPrev" />
                                                           <telerik:RadDataPagerButtonField FieldType="Numeric" />
                                                           <telerik:RadDataPagerButtonField FieldType="NextLast" />
                                                           <telerik:RadDataPagerPageSizeField PageSizeComboWidth="60" PageSizeText="Page size:" />
                                                           <telerik:RadDataPagerGoToPageField CurrentPageText="Page:" TotalPageText="of" SubmitButtonText="Go" TextBoxWidth="25" />
                                                           <telerik:RadDataPagerTemplatePageField Visible="true">
                                                                <PagerTemplate>
                                                                    <div style="float: right; padding-left: 50px;">
                                                                        <strong>
                                                                            <asp:Label runat="server" ID="lblCurrentPageLabel" Text='<%# IIF(Container.Owner.TotalRowCount > 0, Container.Owner.StartRowIndex + 1, 0) %>'></asp:Label>
                                                                            to <asp:Label runat="server" ID="lblTotalPagesLabel" Text='<%# IIF(Container.Owner.TotalRowCount >0, Container.Owner.StartRowIndex + Container.Owner.PageSize, 0) %>'></asp:Label> of
                                                                         <asp:Label runat="server" ID="lblTotalItemsLabel" Text='<%# Container.Owner.TotalRowCount  %>'></asp:Label>
                                                                        </strong>
                                                                    </div>
                                                                </PagerTemplate>
                                                           </telerik:RadDataPagerTemplatePageField>
                                                        </Fields>
                                                    </telerik:RadDataPager>
                                                </td>
                                            </tr>
                                        </table>
                                        <asp:PlaceHolder runat="server" ID="AssignmentsContainer"> </asp:PlaceHolder>
                                            <div style="clear:both"> </div>
                                                <table runat="server" style="width:100%; margin-top:5px">
                                                    <tr>
                                                        <td style="width: 25%;">
                                                          <telerik:RadButton runat="server" ID="btnInitInsert" OnClick="btnInitInsert_Click" Text="New Assignment"></telerik:RadButton>
                                                        </td>
                                                        <td style="text-align: right; width: 75%;">
                                                            <asp:Label runat="server" ID="lblSort1" Text="Sorty by:" AssociatedControlID="ddListSort" Style="padding-right: 5px;" ></asp:Label>
                                                            <telerik:RadComboBox runat="server" ID="ddListSort" AutoPostBack="true" OnSelectedIndexChanged="ddListSort_SelectedIndexChanged">
                                                                <Items>
                                                                    <telerik:RadComboBoxItem Text="-Select field to sort-" Value="" />
                                                                    <telerik:RadComboBoxItem Text="Assignment Title" Value="AssignmentName" />
                                                                    <telerik:RadComboBoxItem Text="Assighment Description" Value="AssignmentDesc" />
                                                                    <telerik:RadComboBoxItem Text="DateAssigned" Value="DateAssigned" />
                                                                    <telerik:RadComboBoxItem Text="DateToBeCompleted" Value="DateToBeCompleted" />
                                                                    <telerik:RadComboBoxItem Text="DateCompleted" Value="DateCompleted" />
                                                                </Items>
                                                            </telerik:RadComboBox>
                                                            <asp:RadioButtonList RepeatLayout="Flow" runat="server" RepeatDirection="Horizontal" ID="rblSort" OnSelectedIndexChanged="rblSort_SelectedIndexChanged">
                                                                <asp:ListItem Text="Ascending" Value="ASC" Selected="True"></asp:ListItem>
                                                                <asp:ListItem Text="Descending" Value="DESC"></asp:ListItem>
                                                            </asp:RadioButtonList>
                                                        </td>
                                                    </tr>
                                                </table>
                                           </fieldset>                                 
                                    </LayoutTemplate>
                                    <ItemTemplate>
                                        <fieldset class="fieldset">
                                            <legend>Student Name: <asp:Label runat="server" ID="idLegendStudentName"></asp:Label> </legend>
                                            <table cellpadding="0" cellspacing="0" style="height: 100%;" width="100%">
                                                <tr>
                                                    <td>
                                                        <table cellpadding="0" cellspacing="0" style="width: 95%;">
                                                            <tr>
                                                                <td>
                                                                    <table cellpadding="0" cellspacing="0">
                                                                        
                                                                        <tr>
                                                                            <td style="width: 50%">
                                                                               Assignment Name:
                                                                            </td>
                                                                           <td style="width: 50%">
                                                                                <%#Eval("AssignmentName")%>
                                                                            </td>
                                                                        </tr>
                                                                         <tr>
                                                                            <td style="width: 50%">
                                                                               Assignment Desc:
                                                                            </td>
                                                                           <td style="width: 50%">
                                                                                <%#Eval("AssignmentDesc")%>
                                                                            </td>
                                                                        </tr>
                                                                        <tr>
                                                                            <td style="width: 50%">
                                                                               Date Assigned
                                                                            </td>
                                                                           <td style="width: 50%">
                                                                                <%#Eval("DateAssigned")%>
                                                                            </td>
                                                                        </tr>
                                                                         <tr>
                                                                            <td style="width: 50%">
                                                                               DateToBeCompleted
                                                                            </td>
                                                                           <td style="width: 50%">
                                                                                <%#Eval("DateToBeCompleted")%>
                                                                            </td>
                                                                        </tr>
                                                                            <tr>
                                                                            <td style="width: 50%">
                                                                               DateCompleted
                                                                            </td>
                                                                           <td style="width: 50%">
                                                                                <%#Eval("DateCompleted")%>
                                                                            </td>
                                                                        </tr>
                                                                        <tr>
                                                                            <td style="width: 50%">
                                                                               Assignment Completed?
                                                                            </td>
                                                                           <td style="width: 50%">
                                                                                <asp:RadioButton runat="server" ID="rdIncompleted" GroupName="AssignmentCompleted" Checked="false" Text="Assignment Incomplete"  />
                                                                                <asp:RadioButton runat="server" ID="rdCompleted" GroupName="AssignmentCompleted" Checked="false" Text="Assignment Completed" />
                                                                                <asp:RadioButton runat="server" ID="rdNotDecided" GroupName="AssignmentCompleted"  Text="Not Decided Yet" Checked="true" />
                                                                            </td>
                                                                        </tr>
                                                                    </table>
                                                                </td>
                                                            </tr>
                                                        </table>
                                                    </td>
                                                </tr>
                                                <tr>
                                                    <td>
                                                        <table style="width: 95%; margin-top: 30px">
                                                            <tr>
                                                                <td>
                                                                    <telerik:RadButton runat="server" ID="btnEdit" CommandName="Edit" Width="70px" Text="Edit"></telerik:RadButton>
                                                                </td>
                                                                <td style="text-align: right">
                                                                    <telerik:RadButton runat="server" ID="btnDelete" CommandName="Delete" Width="70px" Text="Delete"></telerik:RadButton>
                                                                </td>
                                                            </tr>
                                                        </table>
                                                    </td>
                                                </tr>
                                            </table>
                                        </fieldset>
                                    </ItemTemplate>
                                    <EditItemTemplate>
                                      <fieldset class="fieldset">
                                        <table runat="server" cellpadding="0" cellspacing="0" width="100%" style="height: 80%;" >
                                            <tr>
                                                <td>
                                                    <table runat="server" cellpadding="0" cellspacing="0" style="width: 95%; margin-bottom: 5px">
                                                        <tr>
                                                            <td>
                                                                <table runat="server" cellpadding="0" cellspacing="0">
                                                                    <tr>
                                                                        <td style="width: 50%">
                                                                            Assignment Name:
                                                                        </td>
                                                                        <td style="width: 75%">
                                                                            <asp:TextBox runat="server" ID="txtAssignmentName" Text='<%# Bind("AssignmentName") %>'></asp:TextBox>
                                                                            <asp:RequiredFieldValidator runat="server" ID="rqAssignmentName"  ControlToValidate="txtAssignmentName" ErrorMessage="You need to enter assignment name." Display="Dynamic"></asp:RequiredFieldValidator>
                                                                        </td>
                                                                    </tr>
                                                                    <tr>
                                                                        <td style="width: 50%">
                                                                            Assignment Desc:
                                                                        </td>
                                                                        <td style="width: 75%">
                                                                            <asp:TextBox runat="server" ID="txtAssignmentDesc" Text='<%# Bind("AssignmentDesc") %>'></asp:TextBox>
                                                                            <asp:RequiredFieldValidator runat="server" ID="rqAssignmentDesc" ControlToValidate="txtAssignmentDesc" ErrorMessage="You need to enter assignment description." Display="Dynamic"></asp:RequiredFieldValidator>
                                                                        </td>
                                                                    </tr>
                                                                     <tr>
                                                                        <td style="width: 50%">
                                                                            Date Assigned:
                                                                        </td>
                                                                        <td style="width: 75%">
                                                                            <asp:TextBox runat="server" id="rdpDateAssigned" Text = '<%# Bind("DateAssigned") %>'> </asp:TextBox>                                                                  
                                                                            <asp:RequiredFieldValidator runat="server" ID="rqDateAssigned" ControlToValidate="rdpDateAssigned" ErrorMessage="You need to enter assigned date." Display="Dynamic"></asp:RequiredFieldValidator>
                                                                        </td>
                                                                    </tr>
                                                                     <tr>
                                                                        <td style="width: 50%">
                                                                            Date To Be Completed:
                                                                        </td>
                                                                        <td style="width: 75%">
                                                                            <asp:TextBox runat="server" id="txtDateToBeCompleted" Text = '<%# Bind("DateToBeCompleted") %>'> </asp:TextBox>                                                                  
                                                                            <asp:RequiredFieldValidator runat="server" ID="rqDateToBeCompleted" ControlToValidate="txtDateToBeCompleted" ErrorMessage="You need to enter date to be completed." Display="Dynamic"></asp:RequiredFieldValidator>
                                                                        </td>
                                                                    </tr>
                                                                    <tr>
                                                                        <td style="width: 50%">
                                                                            Date Completed:
                                                                        </td>
                                                                        <td style="width: 75%">
                                                                            <asp:TextBox runat="server" id="txtDateCompleted" Text = '<%# Bind("DateCompleted") %>'> </asp:TextBox>
                                                                        </td>
                                                                    </tr>
                                                                    <tr>
                                                                        <td colspan="2">
                                                                            <div style="float:left; padding-left: 30%">
                                                                                <asp:Button runat="server" ID="btnUpdate" Text="Update" CommandName="Update" />
                                                                                <asp:Button runat="server" ID="btnCancel" Text="Cancel" CommandName="Cancel" CausesValidation="false" />
                                                                            </div>
                                                                        </td>
                                                                    </tr>
                                                                </table>
                                                            </td>
                                                        </tr>
                                                    </table>
                                                        </td>
                                            </tr>
                                        </table>
                                                   </fieldset>
                                             
                                     
                                    </EditItemTemplate>
                                    <InsertItemTemplate>
                                        <fieldset class="fieldset" style="clear: left; width: 540px">
                                            <table cellpadding="0" cellspacing="0" style="height: 80%;" width="100%">
                                                <tr>
                                                    <td>
                                                        <table cellpadding="0" cellspacing="0" style="width: 95%; margin-bottom: 5px">
                                                            <tr>
                                                                <td  style="width: 50%">
                                                                    <table runat="server" cellpadding="0" cellspacing="0" style="width: 95%; margin-bottom: 5px">
                                                                        <tr>
                                                                            <td style="width: 50">
                                                                                Assignment Name:
                                                                            </td>
                                                                            <td style="width: 75%">
                                                                                <asp:TextBox ID="txtAssignmentName" runat="server" Text='<%# Bind("AssignmentName") %>'></asp:TextBox>
                                                                                <asp:RequiredFieldValidator runat="server" ID="rqAssignmentName" ErrorMessage="Please enter assignment name." Display="Dynamic" ControlToValidate="txtAssignmentName"></asp:RequiredFieldValidator>
                                                                            </td>
                                                                        </tr>
                                                                        <tr>
                                                                            <td style="width: 50">
                                                                                Assignment Desc:
                                                                            </td>
                                                                            <td style="width: 75%">
                                                                                <asp:TextBox ID="txtAssignmentDesc" runat="server" Text='<%# Bind("AssignmentDesc") %>'></asp:TextBox>
                                                                                <asp:RequiredFieldValidator runat="server" ID="rqAssignmentDesc" ErrorMessage="Please enter assignment description." Display="Dynamic" ControlToValidate="txtAssignmentDesc"></asp:RequiredFieldValidator>
                                                                            </td>
                                                                        </tr>
                                                                        <tr>
                                                                            <td style="width: 50">
                                                                                Date Assigned:
                                                                            </td>
                                                                            <td style="width: 75%">
                                                                                <asp:TextBox ID="txtDateAssigned" runat="server" Text='<%# Bind("DateAssigned") %>'></asp:TextBox>
                                                                                <asp:RequiredFieldValidator runat="server" ID="rqDateAssigned" ErrorMessage="Please enter assigned date." Display="Dynamic" ControlToValidate="txtDateAssigned"></asp:RequiredFieldValidator>
                                                                            </td>
                                                                        </tr>
                                                                        <tr>
                                                                            <td style="width: 50">
                                                                                Date To Be Completed:
                                                                            </td>
                                                                            <td style="width: 75%">
                                                                                <asp:TextBox ID="txtDateToBeCompleted" runat="server" Text='<%# Bind("DateToBeCompleted") %>'></asp:TextBox>
                                                                                <asp:RequiredFieldValidator runat="server" ID="rqDateToBeCompleted" ErrorMessage="Please enter date to be completed." Display="Dynamic" ControlToValidate="txtDateToBeCompleted"></asp:RequiredFieldValidator>
                                                                            </td>
                                                                        </tr>
                                                                        <tr>
                                                                            <td style="width: 50">
                                                                                Date Completed:
                                                                            </td>
                                                                            <td style="width: 75%">
                                                                                <asp:TextBox ID="txtDateCompleted" runat="server" Text='<%# Bind("DateCompleted") %>'></asp:TextBox>
                                                                                
                                                                            </td>
                                                                        </tr>
                                                                        <tr>
                                                                            <td colspan="2">
                                                                                <div style="float: left; padding-left: 40%;">
                                                                                    <asp:Button runat="server" ID="btnPerformInsert"  Text="Insert" CommandName="PerformInsert" />
                                                                                    <asp:Button runat="server" ID="btnCancel" Text="Cancel" CommandName="PerformCancel" CausesValidation="false" />
                                                                                </div>
                                                                            </td>
                                                                        </tr>
                                                                    </table>
                                                                </td>
                                                            </tr>
                                                        </table>
                                                    </td>
                                                </tr>
                                            </table>
                                        </fieldset>
                                    </InsertItemTemplate>
                                </telerik:RadListView>
                            </asp:Panel>
                         </td>
                      </tr>
                   </table>    
     
               </td>
            </tr>
     
                 <tr>
                <td>
                    <asp:Button runat="server" ID="btnUpdateRecord" OnClick="btnUpdateRecord_Click" Text="Update" /> <asp:Label runat="server" ID="idCondition" ForeColor="Red" Width="300px"></asp:Label>
                </td>
                <td>
                     <asp:Button runat="server" ID="btnNewAssignment" OnClick="btnNewAssignment_Click" Text="New Assignment" />
                </td>
            </tr>
            
         </table>
    <telerik:RadListView ID="RadListView2" DataSourceID="SqlDataSource2" runat="server"
                            ItemPlaceholderID="CategoriesContainer" GroupPlaceholderID="GroupCategoriesContainer"
                            GroupItemCount="3" DataKeyNames="homeworkID" OnSelectedIndexChanged="RadListView2_SelectedIndexChanged">
                            <LayoutTemplate>
                                <fieldset id="GroupCategoriesContainer" runat="server">
                                </fieldset>
                            </LayoutTemplate>
                            <GroupTemplate>
                                <fieldset style="float: left;">
                                    <legend>Categories group</legend>
                                    <table>
                                        <tr>
                                            <asp:PlaceHolder ID="CategoriesContainer" runat="server"></asp:PlaceHolder>
                                        </tr>
                                    </table>
                                </fieldset>
                            </GroupTemplate>
                            <EmptyItemTemplate>
                                <td>
                                                                    <div class="itemDiv">
                                          
                                    </div>
                                </td>
                            </EmptyItemTemplate>
                            <SelectedItemTemplate>
                                <td>
                                    <asp:LinkButton ID="imgButton" runat="server" CommandName="Select">
                                        <telerik:RadBinaryImage ID="RadBinaryImage1" runat="server" AlternateText="Category Photo"
                                            Style="margin-left: 10px" ToolTip="Category Photo" Width="90px" Height="62px"
                                            BorderColor="#58954D" BorderWidth="2px" ResizeMode="Fit" ImageUrl='<%# string.Format("IMG/{0}.jpg", Eval("CategoryID")) %>'>
                                        </telerik:RadBinaryImage>
                                    </asp:LinkButton>
                                    <div class="selectedDiv">
                                        <%#Eval("homeworkID")%>
                                    </div>
                                </td>
                            </SelectedItemTemplate>
                        </telerik:RadListView>
         <asp:SqlDataSource SelectCommandType="Text" SelectCommand="Select [UserID], FullName FROM [BulletinBoardDataBase].[dbo].[tbl_RegistrationForm]" ID="SqlDataSource1" runat="server" ConnectionString="Data Source=ENTERDUMMYINFOHERE-PC\ENTERDUMMYINFOHERE;Initial Catalog=BulletinBoardDataBase;Integrated Security=True">
         </asp:SqlDataSource>
           <asp:SqlDataSource SelectCommandType="Text" InsertCommand="INSERT INTO [dbo].[tbl_HomeWork] ([homeworkID] ,[UserID], [DateAssigned],[DateToBeCompleted],[AssignmentName],[AssignmentDesc],[AssignmentCompleted],[AssignmentIncomplete],[DateCompleted]) VALUES (@homeworkID ,@UserID , @DateAssigned, @DateToBeCompleted, @AssignmentName ,@AssignmentDesc ,@AssignmentCompleted ,@AssignmentIncomplete ,@DateCompleted)" DeleteCommand="DELETE FROM [BulletinBoardDataBase].[dbo].[tbl_HomeWork] Where UserID=@UserID And homeworkID=@homeworkID" UpdateCommand="UPDATE FROM [BulletinBoardDataBase].[dbo].[tbl_HomeWork] Set DateAssigned=@DateAssigned,DateCompleted=@DateCompleted, DateToBeCompleted=@DateToBeCompleted, AssignmentName=@AssignmentName, AssignmentDesc=@AssignmentDesc, AssignmentCompleted=@AssignmentCompleted, AssignmentInComplete=@AssignmentInComplete Where UserID = @UserID" SelectCommand="SELECT [homeworkID],[UserID],[DateAssigned],[DateToBeCompleted],[DateCompleted],[AssignmentName],[AssignmentDesc] FROM [BulletinBoardDataBase].[dbo].[tbl_HomeWork] Where UserID=@UserID" ID="SqlDataSource2" runat="server" ConnectionString="Data Source=ENTERDUMMYINFOHERE-PC\ENTERDUMMYINFOHERE;Initial Catalog=BulletinBoardDataBase;Integrated Security=True">
                <SelectParameters>
                    <asp:Parameter Name="UserID" Type="Int32" />
                </SelectParameters>
                <UpdateParameters>
                    <asp:Parameter Name="UserID" Type="Int32" />
                    <asp:Parameter Name="DateAssigned" Type="DateTime" />
                    <asp:Parameter Name="DateToBeCompleted" Type="DateTime" />
                    <asp:Parameter Name="AssignmentName" Type="String" />
                    <asp:Parameter Name="AssignmentDesc" Type="String" />
                    <asp:Parameter Name="AssignmentCompleted" Type="Boolean" />
                    <asp:Parameter Name="AssignmentInComplete" Type="Boolean" />
                    <asp:Parameter Name="DateCompleted" Type="DateTime" />
                </UpdateParameters>
                <DeleteParameters>
                    <asp:Parameter Name="UserID" Type="Int32" />
                    <asp:Parameter Name="homeworkID" Type="Int32" />
                </DeleteParameters>
                <InsertParameters>
                    <asp:Parameter Name="homeworkID" Type="Int32" />
                    <asp:Parameter Name="UserID" Type="Int32" />
                    <asp:Parameter Name="DateAssigned" Type="DateTime" />
                    <asp:Parameter Name="DateToBeCompleted" Type="DateTime" />
                    <asp:Parameter Name="AssignmentName" Type="String" />
                    <asp:Parameter Name="AssignmentDesc" Type="String" />
                    <asp:Parameter Name="AssignmentCompleted" Type="Boolean" />
                    <asp:Parameter Name="AssignmentIncomplete" Type="Boolean" />
                    <asp:Parameter Name="DateCompleted" Type="DateTime" />
                </InsertParameters>
         </asp:SqlDataSource>
        
    </asp:Content>


    Down here is the backend code:

    Imports System.Data.SqlClient
    Imports System.Data
    Imports System.Net.Mail
    Imports Telerik.Web.UI
     
    Partial Class EditAssignHomework
        Inherits System.Web.UI.Page
        Private lngHomeUSerID As Long()
        Private connectionString As String = "Data Source=ENTERDUMMYDATAHERE-PC\ENTERDUMMYDATAHERE;Initial Catalog=BulletinBoardDataBase;Integrated Security=True"
        Protected Sub lstStudentNames_ItemDataBound(sender As Object, e As Telerik.Web.UI.DropDownListItemEventArgs) Handles lstStudentNames.ItemDataBound
            e.Item.Attributes.Add("UserID", TryCast(e.Item.DataItem, DataRowView)("UserID").ToString())
        End Sub
     
     
     
        Protected Sub lstStudentNames_ItemSelected(sender As Object, e As Telerik.Web.UI.DropDownListEventArgs) Handles lstStudentNames.ItemSelected
            Dim selectedItem As Telerik.Web.UI.DropDownListItem = lstStudentNames.SelectedItem
            ViewState("lngUserID") = selectedItem.Attributes("UserID").ToString
            ' Here we are getting details of all the assignments the student have being assigned.
     
            RadListView1.DataBind()
        End Sub
        Protected Sub btnInitInsert_Click(ByVal sender As Object, ByVal e As System.EventArgs)
            RadListView1.ShowInsertItem()
            RadListView1.FindControl("btnInitInsert").Visible = False
     
        End Sub
        Protected Sub lstStudentNames_SelectedIndexChanged(sender As Object, e As Telerik.Web.UI.DropDownListEventArgs) Handles lstStudentNames.SelectedIndexChanged
     
        End Sub
        Protected Sub rblSort_SelectedIndexChanged(ByVal sender As Object, ByVal e As EventArgs)
     
        End Sub
        Protected Sub ddListSort_SelectedIndexChanged(ByVal sender As Object, ByVal e As RadComboBoxSelectedIndexChangedEventArgs)
     
        End Sub
     
        Protected Sub btnUpdateRecord_Click(sender As Object, e As System.EventArgs) Handles btnUpdateRecord.Click
     
        End Sub
     
        Protected Sub btnNewAssignment_Click(sender As Object, e As System.EventArgs) Handles btnNewAssignment.Click
     
        End Sub
        Protected Sub RadListView1_ItemCommand(sender As Object, e As Telerik.Web.UI.RadListViewCommandEventArgs) Handles RadListView1.ItemCommand
            If (e.CommandName = RadListView.PerformInsertCommandName) OrElse (e.CommandName = RadListView.UpdateCommandName) OrElse (e.CommandName = RadListView.CancelCommandName) Then
                RadListView1.InsertItemPosition = RadListViewInsertItemPosition.None
                RadListView1.FindControl("btnInitInsert").Visible = True
                RadListView2.Visible = True
            End If
     
     
        End Sub
     
        Protected Sub SqlDataSource2_Deleting(sender As Object, e As System.Web.UI.WebControls.SqlDataSourceCommandEventArgs) Handles SqlDataSource2.Deleting
            e.Command.Parameters("@UserID").Value = ViewState("lngUserID")
     
            ' Dim fvLabel As Label = DirectCast(CType(Page.FindControl("lblHomeWorkID"), Label), Label)
            ' e.Command.Parameters("@homeworkID").Value = fvLabel.Text
     
        End Sub
     
        Protected Sub SqlDataSource2_Inserting(sender As Object, e As System.Web.UI.WebControls.SqlDataSourceCommandEventArgs) Handles SqlDataSource2.Inserting
            ViewState("lnghomeworkID") = Convert.ToInt32(ViewState("lnghomeworkID")) + 1
            e.Command.Parameters("@homeworkID").Value = ViewState("lnghomeworkID")
            e.Command.Parameters("@UserID").Value = ViewState("lngUserID")
     
            ' First before we retrieve password we are going to check first to make sure that the user actually exist
            Dim connection As New SqlConnection(connectionString)
            Dim command As New SqlCommand
            command.Connection = connection
            command.CommandText = "Select * From [BulletinBoardDataBase].[dbo].[tbl_RegistrationForm] Where UserID='" & ViewState("lngUserID") & "'"
            connection.Close()
            connection.Open()
            Dim reader As SqlDataReader = command.ExecuteReader()
            Dim email As String = Nothing
            Dim FullName As String = Nothing
     
            While (reader.Read())
                email = reader("Email")
                FullName = reader("FullName")
            End While
            connection.Close()
     
            connection.Close()
            Dim Message As New MailMessage("fakeemail@gmail.com", email, "Assignment assigned to " & FullName & ".", "This is an automatic message. Please do not reply back to this email. If you have questions to ask about the assignment please email fakedemail@gmail.com, thank you. " & FullName & " you have a new assignment assigned to you. Please login to your profile to obtain your assignment if you do not fulfill your assignment at the deadline it is assigned to you it will go to the incomplete assignment.")
            Dim client As New SmtpClient()
            client.Send(Message)
        End Sub
     
        Protected Sub SqlDataSource2_Selecting(sender As Object, e As System.Web.UI.WebControls.SqlDataSourceSelectingEventArgs) Handles SqlDataSource2.Selecting
            e.Command.Parameters("@UserID").Value = ViewState("lngUserID")
     
        End Sub
        Protected Sub Page_Load(sender As Object, e As System.EventArgs) Handles Me.Load
     
        End Sub
        Protected Sub RadListView1_ItemDataBound(sender As Object, e As Telerik.Web.UI.RadListViewItemEventArgs) Handles RadListView1.ItemDataBound
     
        End Sub
     
        Protected Sub RadListView1_PreRender(sender As Object, e As System.EventArgs) Handles RadListView1.PreRender
            'Try
            '    For Each item As RadListViewDataItem In RadListView1.Items
     
            '        hiddenListBox.Items.Add(CType(item.FindControl("lblHomeWorkID"), Label).Text)
            '        hiddenListBox.DataBind()
            '    Next
            'Catch ex As Exception
     
            'End Try
             
        End Sub
        Protected Sub RadListView1_SelectedIndexChanged(sender As Object, e As System.EventArgs) Handles RadListView1.SelectedIndexChanged
     
        End Sub
     
     
    End Class

    Any help on this would be SUPER sweet!!
  2. Eyup
    Admin
    Eyup avatar
    3014 posts

    Posted 07 May 2013 Link to this post

    Hello Fahed,

    I have already replied to your query in your ticket 688890. Can you please check out the suggested demo and let me know if it helps you?
    http://demos.telerik.com/aspnet-ajax/listview/examples/dataediting/manualediting/defaultcs.aspx

    Regards,
    Eyup
    the Telerik team
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. xboxown
    xboxown avatar
    2 posts
    Member since:
    Nov 2011

    Posted 08 May 2013 Link to this post

    Thank you! The problem is solved :)

    Appreciate it for your help! :)
Back to Top