Telerik Forums
UI for ASP.NET AJAX Forum
1 answer
89 views
Hi Team and Dear all,

I have ready to creat web applications using Control Telerik.

When I not use Telerik Control in Page Login after published in IIS.
I call my web in URL ,: http://localhost:8080/
event button click is Fine and Work call code behind Process..

but, when I using Control Telerik,like RadScriptmanager and others...
when I click button Login,that not work...
When I call URL this "http://localhost:8080/" it's no work, but when I add specific page like " http://localhost:8080/default.aspx" ,it;'s work..

in IE,Firefox and GoogleChome it's not Work....

this, my code, my be i was wrong something or anything else...
please help me..
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="eRTE.Default" %>
<!DOCTYPE html>
 
<head runat="server">
    <title>eRTE</title>
    <link href="~/Content/Site.css" rel="stylesheet" />
</head>
<body>
    <form id="form1" runat="server">
         
         
    <div>
    <asp:ScriptManager runat="server" ID="ScriptManager1"></asp:ScriptManager>
        <telerik:RadStyleSheetManager ID="RadStyleSheetManager1" runat="server">
        </telerik:RadStyleSheetManager>
        <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
        </telerik:RadAjaxManager>
        <telerik:RadWindowManager ID="RadWindowManager1" runat="server" Skin="Metro">
        </telerik:RadWindowManager>
     
    </div>
    <div style="height: 175px">
     
    </div>
 
        <div style="height: 150px">
            <table style="width: 100%">
                <tr>
                    <td align="center" colspan="3">
                        <img alt="logo" src="Images/logosystem.png" />
                    </td>
                </tr>
                <tr>
                    <td style="width: 40%"></td>
                    <td>
                        <table style="width: 100%">
                            <tr><td>
                                    <span style="font-size: 13px;color: #666;">USERNAME</span>
                                </td><td><span style="font-size: 13px;color: #666;">PASSWORD</span>
                                     </td></tr>
                            <tr><td>
                                         <telerik:RadTextBox runat="server" ID="tbusername" AutoCompleteType="Disabled"></telerik:RadTextBox>
                                </td><td>
                                         <telerik:RadTextBox runat="server" ID="tbpass" TextMode="Password" AutoCompleteType="Disabled"></telerik:RadTextBox>
                                     </td></tr>
                            <tr><td>
                                    <asp:Button Text="Login" ID="btnLogin" runat="server" CssClass="buttonsubmit" Width="75px" OnClick="btnLogin_Click"/>                                </td><td></td></tr>
                        </table>
                         
                    </td>
                    <td style="width: 35%"></td>
                </tr>
                <tr>
                    <td style="width: 40%"> </td>
                    <td>
                             <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="tbusername" CssClass="field-validation-error" ErrorMessage="The user name field is required." /><br />
                            <asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ControlToValidate="tbpass" CssClass="field-validation-error" ErrorMessage="The password field is required." />
     
                    </td>
                    <td style="width: 35%"> </td>
                </tr>
            </table>
 
        </div>
        <div style="height: 250px"></div>
        <div style="text-align: center; color: #333;font-size: 12px;" >
Copyright ©  <%: DateTime.Now.Year.ToString() %>· All rights reserved.
        </div>
    </form>
</body>
</html>

and this code behind

using System;
using System.Collections.Generic;
using System.Configuration;
using System.Globalization;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
 
namespace eRTE
{
    public partial class Default : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            Form.DefaultButton = btnLogin.ClientID;
            Form.DefaultFocus = tbusername.UniqueID;
            if (!IsPostBack && (Request.Cookies["__LOGINCOOKIE__"] == null || Request.Cookies["__LOGINCOOKIE__"].Value == ""))
            {
 
                Session.Abandon();
                Response.Cookies.Add(new HttpCookie("ASP.NET_SessionId", ""));
            }
 
 
 
        }
 
        private void AddRedirCookie(string userdata)
        {
        }
 
        protected void btnLogin_Click(object sender, EventArgs e)
        {
 
           //this my code process event login,
          // when I using control telerik, can't  proses to this event...why..???
        }
 
 
    }
}

trims a lot,

best reagrds,

chester
BabaYa
Top achievements
Rank 1
 answered on 24 Jul 2013
1 answer
179 views
I have a screen that has a Radgrid.  The radgrid uses a user control for the edit form.  When the edit button is pressed on the grid it loades the user control.  The User control is just a series of textboxes that are bound to the data from the grid.
<asp:TextBox ID="FamilyID" runat="server" value='<%# DataBinder.Eval(Container, "DataItem.FamilyID") %>'></asp:TextBox>

On the load event of this control there are a series of buttons that I want to make visible depending on the values in the text boxes.  The ossue I am having is since the values are set with DataBinder.Eval they do not have a value on the page_Load event.  How do I get the values so I can alter the screen?



Jayesh Goyani
Top achievements
Rank 2
 answered on 24 Jul 2013
2 answers
108 views
Hi,

I cannot fix this issue about missing resource value. On the radScheduler it shows Telerik.Web.UI.Resource instead of the value. Any ideas? thank you.
here is the code:

<telerik:RadScheduler ID="RadScheduler1"
    CustomAttributeNames="EndTime,StartTime" CssClass="testing" OnClientAppointmentResizing="pereventResize"
    OnClientAppointmentMoveStart="PreventDragDrop" runat="server" DataEndField="EndTime"
    DataKeyField="Id" DataSourceID="SqlDataSource1" DataStartField="StartTime" DataSubjectField="Subject"
    Height="" Skin="Office2010Blue" StartEditingInAdvancedForm="False" DayEndTime="20:00:00"
    DayStartTime="09:00:00" FirstDayOfWeek="Monday" LastDayOfWeek="Sunday" OnAppointmentInsert="RadScheduler1_AppointmentInsert"
    OnAppointmentUpdate="RadScheduler1_AppointmentUpdate" WorkDayEndTime="20:00:00"
    WorkDayStartTime="09:00:00" AllowDelete="False" DataDescriptionField="Description"
    DataRecurrenceField="RecData" DataRecurrenceParentKeyField="RecParrent"
    EnableDescriptionField="True">
    <ResourceTypes>
        <telerik:ResourceType DataSourceID="SqlDataSource2"
            ForeignKeyField="MeetingRoomID" KeyField="ID" Name="Floor"
            TextField="MeetingRoomFloor" />
    </ResourceTypes>
    <AppointmentTemplate>
        <div>
            <h2>
                <%#Eval("Subject") %>
            </h2>
            <p>
                <%#Eval("Description") %></p>   <%#Eval("Floor") %>
                 
        </div>
    </AppointmentTemplate>
</telerik:RadScheduler>
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:CompanyInfoEventsConnectionString %>"
    DeleteCommand="DELETE FROM [Event] WHERE [Id] = @Id" InsertCommand="INSERT INTO [Event] ([Subject], [StartTime], [EndTime], [Description], [RecParrent], [RecData], [MeetingRoomID]) VALUES (@Subject, @StartTime, @EndTime, @Description, @RecParrent, @RecData, @MeetingRoomID)"
    SelectCommand="SELECT * FROM [Event]"
     
    UpdateCommand="UPDATE [Event] SET [Subject] = @Subject, [StartTime] = @StartTime, [EndTime] = @EndTime, [Description] = @Description, [RecParrent] = @RecParrent, [RecData] = @RecData, [MeetingRoomID] = @MeetingRoomID WHERE [Id] = @Id">
    <DeleteParameters>
        <asp:Parameter Name="Id" Type="Int32" />
    </DeleteParameters>
    <InsertParameters>
        <asp:Parameter Name="Subject" Type="String" />
        <asp:Parameter Name="StartTime" Type="DateTime" />
        <asp:Parameter Name="EndTime" Type="DateTime" />
        <asp:Parameter Name="Description" Type="String" />
        <asp:Parameter Name="RecParrent" Type="Int32" />
        <asp:Parameter Name="RecData" Type="String" />
        <asp:Parameter Name="MeetingRoomID" Type="Int32" />
    </InsertParameters>
    <UpdateParameters>
        <asp:Parameter Name="Subject" Type="String" />
        <asp:Parameter Name="StartTime" Type="DateTime" />
        <asp:Parameter Name="EndTime" Type="DateTime" />
        <asp:Parameter Name="Description" Type="String" />
        <asp:Parameter Name="RecParrent" Type="Int32" />
        <asp:Parameter Name="RecData" Type="String" />
        <asp:Parameter Name="MeetingRoomID" Type="Int32" />
        <asp:Parameter Name="Id" Type="Int32" />
    </UpdateParameters>
</asp:SqlDataSource>
 
<asp:SqlDataSource ID="SqlDataSource2" runat="server"
    ConnectionString="<%$ ConnectionStrings:CompanyInfoEventsConnectionString %>"
    DeleteCommand="DELETE FROM [MeetRoomFloor] WHERE [ID] = @ID"
    InsertCommand="INSERT INTO [MeetRoomFloor] ([MeetingRoomFloor]) VALUES (@MeetingRoomFloor)"
    SelectCommand="SELECT * FROM [MeetRoomFloor]"
    UpdateCommand="UPDATE [MeetRoomFloor] SET [MeetingRoomFloor] = @MeetingRoomFloor WHERE [ID] = @ID">
    <DeleteParameters>
        <asp:Parameter Name="ID" Type="Int32" />
    </DeleteParameters>
    <InsertParameters>
        <asp:Parameter Name="MeetingRoomFloor" Type="String" />
    </InsertParameters>
    <UpdateParameters>
        <asp:Parameter Name="MeetingRoomFloor" Type="String" />
        <asp:Parameter Name="ID" Type="Int32" />
    </UpdateParameters>
</asp:SqlDataSource>
Zura Chikhladze
Top achievements
Rank 1
 answered on 24 Jul 2013
11 answers
122 views
I am using Telerik ASPX / AJAX v.2011.3.1305.40

I have a page with a RadButton and an AsyncUpload (see aspx code below) a- along with other controls. If I first select a file using the AsyncUpload it will display the selected file (and waits until I click another button to actually do something with it). However, if I click btnClear, it clears the AsyncUpload control back to its original state. What do I need to do to prevent this from happening?

Thanks,
Andy

        <script type="text/javascript">
            function btnClear_Click( sender, eventArgs )
            {
                var ddl = $find( "<%= dropdownlist.ClientID %>" );
                ddl.set_text( "" );
                ddl.trackChanges();
                ddl.get_items().getItem( 0 ).set_text( "" );
                ddl.commitChanges();
                var tree = ddl.get_items().getItem( 0 ).findControl( "treeview" );
                var selectedNode = tree.get_selectedNode();
                if ( selectedNode != null )
                    selectedNode.set_selected( false );
            }
        </script>

             <telerik:RadButton ID="btnClear" runat="server" Text="" OnClientClicked="btnClear_Click"
                ToolTip="Clear setting">
                <Icon PrimaryIconCssClass="rbRemove" PrimaryIconLeft="4" PrimaryIconTop="4" />
            </telerik:RadButton>

           <div class="upload-panel">
                <h6>
                    1. Select .SEW file to import:</h6>
                <telerik:RadAsyncUpload ID="UploadControl" runat="server" MaxFileInputsCount="1"
                    AllowedFileExtensions="sew" />
            </div>

Bozhidar
Telerik team
 answered on 24 Jul 2013
7 answers
202 views
I want to set the control text but don't know how to get a hold of the control that is within a radgrid. Can someone help?
I have another thread related to this but it was mixed with insert form. I thought it'd be better to have a different thread for it.

Also, RadButton1_Click() is not even invoked if there is RequiredFieldValidator and the field value is empty. How can RequiredFieldValidator be disabled when the button is clicked so that it invokes RadButton1_Click() ?

<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
<div>
  <telerik:RadButton runat="server" ID="RadButton1" AutoPostBack="true" Text="fill data"  ButtonType="LinkButton" onclick="RadButton1_Click"></telerik:RadButton>
</div>
  
<telerik:RadAjaxPanel runat=server>
    <telerik:RadGrid ID="RadGrid1" runat="server" AutoGenerateColumns="False"
            ShowStatusBar="True" GridLines="None"  OnNeedDataSource="RadGrid1_NeedDataSource"   OnUpdateCommand="RadGrid1_UpdateCommand"
            OnInsertCommand="RadGrid1_InsertCommand" OnCreateColumnEditor="RadGrid1_CreateColumnEditor"
            OnPreRender="RadGrid1_PreRender" OnItemDataBound="RadGrid1_ItemDataBound" OnItemCreated="RadGrid1_ItemCreated">
             
            <MasterTableView DataKeyNames="id" CommandItemDisplay="Top">
                <Columns>
                    <telerik:GridBoundColumn HeaderText="Emp" DataField="emp" UniqueName="emp">
  
 
protected void RadButton1_Click(object sender, EventArgs e)
{
        //set the text of emp to something else. How to get a hold of the control in here?
}
Jayesh Goyani
Top achievements
Rank 2
 answered on 24 Jul 2013
5 answers
228 views
Hi

When I select date from the raddatepicker, it is displayed in mm dd yy format in the date input. So how can I change the selected date format to dd mm yyyy format?

Thankyou
Needha
Shinu
Top achievements
Rank 2
 answered on 24 Jul 2013
13 answers
218 views
I am having a problem changing the RadScheduler view in Firefox.  In Internet Explorer I can change from Day to Week to Month to Timeline just fine.  In Firefox it only allows me to change the view once then it gets stuck on one view and will not let me switch views, I click the buttons but it wont do anything until i refresh the page and then it does the same thing all over.  Any ideas? 
Plamen
Telerik team
 answered on 24 Jul 2013
1 answer
201 views
Hi 

There are few input fields and required field validators and I tried to display the error message inside the control which is not completely possible due to browser related issues. So I thought of alerting the error messages on validation failed. But how can I get the error messages in javascript so that I can display them in an alert box? Is this a possible requirement?

Thanks
Ivy
Shinu
Top achievements
Rank 2
 answered on 24 Jul 2013
4 answers
1.4K+ views
Hi

I want to create a radiobutton group in telerik and get the selected item. 

Thanks
Lovella
Shinu
Top achievements
Rank 2
 answered on 24 Jul 2013
1 answer
143 views

i had problem that the "add new reocrd" button not working (only show loading logo, but cannot display the edit template) if there is no record.

on the other hand, if there is at least one row/record, the "add new record" button can work properly.

<telerik:RadAjaxPanel ID="Panel_License" runat="server" Enabled="false" clientevents-onrequeststart="conditionalPostback">
 
                                                            <telerik:RadCodeBlock ID="RadCodeBlock1" runat="server">
                                                            <script type="text/javascript">
                                                                function RowDblClick(sender, eventArgs) {
                                                                    sender.get_masterTableView().editItem(eventArgs.get_itemIndexHierarchical());
                                                                }
                                                            </script>
                                                        </telerik:RadCodeBlock>
 
                                                        <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
                                                            <AjaxSettings>
                                                                <telerik:AjaxSetting AjaxControlID="RadGrid_License">
                                                                    <UpdatedControls>
                                                                        <telerik:AjaxUpdatedControl ControlID="RadGrid_License" LoadingPanelID="RadAjaxLoadingPanel1">
                                                                        </telerik:AjaxUpdatedControl>
                                                                        <telerik:AjaxUpdatedControl ControlID="divMsgs"></telerik:AjaxUpdatedControl>
                                                                    </UpdatedControls>
                                                                </telerik:AjaxSetting>
                                                            </AjaxSettings>
                                                        </telerik:RadAjaxManager>
                                                        <telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" runat="server">
                                                        </telerik:RadAjaxLoadingPanel>
                                                            <telerik:RadGrid ID="RadGrid_License" runat="server" CellSpacing="0"
                                                            DataSourceID="ODS_License" GridLines="None" style="margin-top: 0px"
                                                            AllowFilteringByColumn="True" AllowPaging="True" AllowSorting="True"
                                                            AutoGenerateColumns="False" ShowStatusBar="True" AllowAutomaticDeletes="True"
                                                            AllowAutomaticInserts="True"
                                                            AllowAutomaticUpdates="True" Width="800">
                                                                <MasterTableView AutoGenerateColumns="False"
                                                                    DataKeyNames="License_To_Operate_ID" DataSourceID="ODS_License"
                                                                    AllowFilteringByColumn="False" AllowPaging="False"
                                                                    CommandItemDisplay="Top" OverrideDataSourceControlSorting="true" >
 
                                                                    <CommandItemSettings ExportToPdfText="Export to PDF" />
                                                                    <RowIndicatorColumn FilterControlAltText="Filter RowIndicator column"
                                                                        Visible="True">
                                                                    </RowIndicatorColumn>
                                                                    <ExpandCollapseColumn FilterControlAltText="Filter ExpandColumn column"
                                                                        Visible="True">
                                                                    </ExpandCollapseColumn>
 
                                                                    <Columns>
                                                                        <telerik:GridEditCommandColumn UniqueName="EditCommandColumn">
                                                                        </telerik:GridEditCommandColumn>
                                                                        <telerik:GridBoundColumn DataField="License_To_Operate_ID"
                                                                            FilterControlAltText="Filter License_Number column" HeaderText="License_To_Operate_ID"
                                                                            SortExpression="License_To_Operate_ID" UniqueName="License_To_Operate_ID" Visible="false">
                                                                        </telerik:GridBoundColumn>
                                                                        <telerik:GridBoundColumn DataField="License_Name"
                                                                            FilterControlAltText="Filter License_Name column" HeaderText="License Name"
                                                                            SortExpression="License_Name" UniqueName="License_Name">
                                                                        </telerik:GridBoundColumn>
                                                                        <telerik:GridBoundColumn DataField="License_Number"
                                                                            FilterControlAltText="Filter License_Number column" HeaderText="License Number"
                                                                            SortExpression="License_Number" UniqueName="License_Number">
                                                                        </telerik:GridBoundColumn>
                                                                        <telerik:GridBoundColumn DataField="License_Issuer"
                                                                            FilterControlAltText="Filter License_Issuer column" HeaderText="License Issuer"
                                                                            SortExpression="License_Issuer" UniqueName="License_Issuer">
                                                                        </telerik:GridBoundColumn>
                                                                        <telerik:GridBoundColumn DataField="Valid_From" DataType="System.DateTime"
                                                                            FilterControlAltText="Filter Valid_From column" HeaderText="Valid From"
                                                                            SortExpression="Valid_From" UniqueName="Valid_From" DataFormatString="{0: dd-MMM-yyyy}">
                                                                        </telerik:GridBoundColumn>
                                                                        <telerik:GridBoundColumn DataField="Valid_Till" DataType="System.DateTime"
                                                                            FilterControlAltText="Filter Valid_Till column" HeaderText="Valid Till"
                                                                            SortExpression="Valid_Till" UniqueName="Valid_Till" DataFormatString="{0: dd-MMM-yyyy}">
                                                                        </telerik:GridBoundColumn>
                                                                        <telerik:GridBoundColumn DataField="Issue_date" DataType="System.DateTime"
                                                                            FilterControlAltText="Filter Issue_date column" HeaderText="Issue Date"
                                                                            SortExpression="Issue_date" UniqueName="Issue_date" DataFormatString="{0: dd-MMM-yyyy}">
                                                                        </telerik:GridBoundColumn>
                                                                    </Columns>
                                                                    <EditFormSettings EditFormType="Template">
                                                                        <EditColumn FilterControlAltText="Filter EditCommandColumn1 column"
                                                                            UniqueName="EditCommandColumn1">
                                                                        </EditColumn>
 
                                                                    <FormTemplate>
 
                                                        <table id="Table2" cellspacing="2" cellpadding="1" width="100%" border="1" rules="none"
                                                            style="border-collapse: collapse;">
                                                            <tr class="EditFormHeader">
                                                            <td style="width:100px">
                                                            <asp:Label ID="Label5" Text="License Type" runat="server"></asp:Label>                                                           
                                                            </td>
                                                            <td>
                                                                <telerik:RadDropDownList ID="rdl_license_type" runat="server" DataSourceID="LDS_License_type" DefaultMessage="Please select..."
                                                                 DataValueField="License_ID" DataTextField="License_name" >
                                                                </telerik:RadDropDownList>  
                                                                <%--<asp:Label ID="Lb_License_ID" runat="server" text='<%# Bind("License_ID") %>' Visible="false"></asp:Label>--%>
                                                     
                                                            </td>
                                                            </tr>
                                                            <tr >
                                                            <td >
                                                            <asp:Label ID="lb" Text="License Number" runat="server"></asp:Label>                                                           
                                                            </td>
                                                            <td>
                                                            <asp:TextBox ID="tb_License_Number" runat="server" Text='<%# Bind("License_Number") %>' TabIndex="2"></asp:TextBox>                                                           
                                                            </td>
                                                            </tr>
                                                            <tr>
                                                            <td>
                                                            <asp:Label ID="Label1" Text="License Issuer" runat="server"></asp:Label>
                                                            </td>
                                                            <td>
                                                            <asp:TextBox ID="tb_License_Issuer" runat="server" Text='<%# Bind("License_Issuer") %>' TabIndex="3"></asp:TextBox>
                                                            </td>
                                                            </tr>
                                                            <tr>
                                                            <td>
                                                            <asp:Label ID="Label2" Text="Issue Date" runat="server"></asp:Label>
                                                            </td>
                                                            <td>
                                                            <telerik:RadDatePicker ID="IssueDatePicker" runat="server" MinDate="1/1/1900" DbSelectedDate='<%# Bind("Issue_Date") %>' TabIndex="4"></telerik:RadDatePicker>
                                                            </td>
                                                            </tr>
                                                            <tr>
                                                            <td>
                                                            <asp:Label ID="Label3" Text="Valid From" runat="server"></asp:Label>
                                                            </td>
                                                            <td>
                                                            <telerik:RadDatePicker ID="RadDatePicker_ValidFrom" runat="server" MinDate="1/1/1900" DbSelectedDate='<%# Bind("Valid_From") %>' TabIndex="5"></telerik:RadDatePicker>
                                                            </td>
                                                            </tr>
                                                                                                                        <tr>
                                                            <td>
                                                            <asp:Label ID="Label4" Text="Valid To" runat="server"></asp:Label>
                                                            </td>
                                                            <td>
                                                            <telerik:RadDatePicker ID="RadDatePicker_ValidTill" runat="server" MinDate="1/1/1900" DbSelectedDate='<%# Bind("Valid_Till") %>' TabIndex="6"></telerik:RadDatePicker>
                                                            </td>
                                                            </tr>
 
                                                               <tr>
                                                                <td align="right" colspan="2">
                                                                    <asp:Button ID="btnUpdate" Text='<%# IIf((TypeOf(Container) is GridEditFormInsertItem), "Insert", "Update") %>'
                                                                        runat="server" CommandName='<%# IIf((TypeOf(Container) is GridEditFormInsertItem), "PerformInsert", "Update")%>' >
                                                                    </asp:Button
                                                                    <asp:Button ID="btnDelete" Text="Delete" runat="server" CausesValidation="False"
                                                                        CommandName="Delete"></asp:Button>
                                                                    <asp:Button ID="btnCancel" Text="Cancel" runat="server" CausesValidation="False"
                                                                        CommandName="Cancel"></asp:Button>
 
                                                                </td>
                                                            </tr>
                                                        </table>
                                                    </FormTemplate>
                                                </EditFormSettings>
                                                                    <PagerStyle PageSizeControlType="RadComboBox" />
                                                                </MasterTableView>
                                                                <PagerStyle PageSizeControlType="RadComboBox" />
                                                                <FilterMenu EnableImageSprites="False">
                                                                </FilterMenu>
 
                                                        </telerik:RadGrid>
                                                        <asp:LinqDataSource ID="LDS_License_type" runat="server"
                                                            ContextTypeName="dcLRDBDataContext" EntityTypeName=""
                                                            TableName="db_Dictionary_Licenses">
                                                            </asp:LinqDataSource>
                                                        <asp:ObjectDataSource ID="ODS_License" runat="server"
                                                            SelectMethod="GetLicenseArrayByUserID" TypeName="LRDB">
                                                            <SelectParameters>
                                                                <asp:SessionParameter DefaultValue="0" Name="id" SessionField="SelectedUserID"
                                                                    Type="String" />
                                                            </SelectParameters>
                                                        </asp:ObjectDataSource>
                                                        <asp:LinqDataSource ID="LDS_License" runat="server"
                                                            ContextTypeName="dcLRDBDataContext" EntityTypeName=""
                                                            TableName="db_Employee_Licenses" Where="UserID == @UserID">
                                                            <WhereParameters>
                                                                <asp:SessionParameter Name="UserID" SessionField="SelectedUserID"
                                                                    Type="Int32" DefaultValue="0"/>
                                                            </WhereParameters>
                                                        </asp:LinqDataSource>
                                      <br />
 
        </telerik:RadAjaxPanel>

Public Function GetLicenseArrayByUserID(ByVal id As String) As ArrayList
    Dim arr As New ArrayList
    arr.Clear()
 
    Dim dc As New dcLRDBDataContext
    Dim i As Integer = 0
 
    Dim result = (From cs In dc.db_Dictionary_Licenses _
                  Group Join cs2 In dc.db_Employee_Licenses _
                  On cs.License_ID Equals cs2.License_ID _
                  Into RightTableResults = Group From cs2 In RightTableResults.DefaultIfEmpty _
                                                 Where cs2.UserID = id _
                                                 Select cs2.License_To_Operate_ID, cs2.Issue_date, cs2.License_Issuer, _
                                                 cs2.License_Number, cs2.Valid_From, cs2.Valid_Till, cs.License_Name, _
                                                 cs.License_ID, Have = If(cs2.UserID = id, "YES", "NO") _
                                                 Order By License_Name).Distinct.ToList
    If Not IsNothing(result) Then
        If result.Count > 0 Then
            For i = 0 To result.Count - 1
                arr.Add(result.Item(i))
            Next
        End If
    End If
 
    dc.Dispose()
    Return arr
End Function

Code behind:

Protected Sub RadGrid_License_ItemCommand(ByVal source As Object, ByVal e As Telerik.Web.UI.GridCommandEventArgs) Handles RadGrid_License.ItemCommand
    RadGrid_License.MasterTableView.ClearEditItems()
    Dim rnd As New Random()
    Dim tmpUserID As Integer 'allow 10 digit only
 
    If Request.QueryString("EmployeeID") = "" Or Request.QueryString("EmployeeID") = 0 Then  'New Employee
        tmpUserID = rnd.Next(100000, 999999) & DateTime.Now.Hour & DateTime.Now.Minute
        HttpContext.Current.Session("tmpUserID") = tmpUserID
    End If
 
    If e.CommandName = RadGrid.InitInsertCommandName Then   'Click Add New Record button           
        Dim editColumn As GridEditCommandColumn = CType(RadGrid_License.MasterTableView.GetColumn("EditCommandColumn"), GridEditCommandColumn)
        editColumn.Visible = False
 
    ElseIf (e.CommandName = RadGrid.RebindGridCommandName AndAlso e.Item.OwnerTableView.IsItemInserted) Then
        e.Canceled = True
    Else
        Dim editColumn As GridEditCommandColumn = CType(RadGrid_License.MasterTableView.GetColumn("EditCommandColumn"), GridEditCommandColumn)
        If Not editColumn.Visible Then  'Click Cancel button (both Insert and Update mode)
            editColumn.Visible = True
        End If
 
        Dim ddlLicense_id As RadDropDownList = DirectCast(e.Item.FindControl("rdl_license_type"), RadDropDownList)
        Dim txtLicense_Number As TextBox = DirectCast(e.Item.FindControl("tb_License_Number"), TextBox)
        Dim txtLicense_Issuer As TextBox = DirectCast(e.Item.FindControl("tb_License_Issuer"), TextBox)
        Dim dateIssue As RadDatePicker = DirectCast(e.Item.FindControl("IssueDatePicker"), RadDatePicker)
        Dim dateValidFrom As RadDatePicker = DirectCast(e.Item.FindControl("RadDatePicker_ValidFrom"), RadDatePicker)
        Dim dateValidTill As RadDatePicker = DirectCast(e.Item.FindControl("RadDatePicker_ValidTill"), RadDatePicker)
        Dim dc As New dcLRDBDataContext
 
        ' If (TypeOf e.Item Is GridEditableItem AndAlso e.Item.IsInEditMode) Then
 
        If e.CommandName = "PerformInsert" Then
 
            If Request.QueryString("EmployeeID") = "" Or Request.QueryString("EmployeeID") = 0 Then  'New Employee
                'Dim rnd As New Random()
                'Dim tmpUserID As Integer 'allow 10 digit only
                'tmpUserID = rnd.Next(100000, 999999) & DateTime.Now.Hour & DateTime.Now.Minute
                'HttpContext.Current.Session("tmpUserID") = tmpUserID
 
                dc.insertEmployeeLicense(tmpUserID.ToString, ddlLicense_id.SelectedValue, txtLicense_Number.Text.Trim, txtLicense_Issuer.Text.Trim, _
                                           dateIssue.SelectedDate, dateValidFrom.SelectedDate, dateValidTill.SelectedDate, "Y", DateTime.Now, HttpContext.Current.Session("UserID").ToString)
 
            Else
                dc.insertEmployeeLicense(GetUserIDbyEmployeeID(Request.QueryString("EmployeeID")).ToString, ddlLicense_id.SelectedValue, txtLicense_Number.Text.Trim, txtLicense_Issuer.Text.Trim, _
                                           dateIssue.SelectedDate, dateValidFrom.SelectedDate, dateValidTill.SelectedDate, "N", DateTime.Now, HttpContext.Current.Session("UserID").ToString)
            End If
            RadGrid_License.DataBind()
        ElseIf e.CommandName = "Update" Then
            Dim lid As Integer = e.Item.OwnerTableView.DataKeyValues(e.Item.ItemIndex)("License_To_Operate_ID")
            Dim uid As Integer
            If Request.QueryString("EmployeeID") = "" Or Request.QueryString("EmployeeID") = 0 Then
                uid = HttpContext.Current.Session("tmpUserID").ToString
            Else
                uid = GetUserIDbyEmployeeID(Request.QueryString("EmployeeID")).ToString
            End If
 
            Dim rec = (From p In dc.db_Employee_Licenses Where p.UserID = uid And p.License_To_Operate_ID = lid).FirstOrDefault
            If Not rec Is Nothing Then
                rec.License_ID = ddlLicense_id.SelectedValue
                rec.License_Number = txtLicense_Number.Text.Trim
                rec.License_Issuer = txtLicense_Issuer.Text.Trim
                rec.Issue_date = dateIssue.SelectedDate
                rec.Valid_From = dateValidFrom.SelectedDate
                rec.Valid_Till = dateValidTill.SelectedDate
                rec.LastUpdateBy = HttpContext.Current.Session("UserID")
                rec.LastUpdateDate = DateTime.Now
                dc.SubmitChanges()
            End If
            RadGrid_License.DataBind()
        ElseIf e.CommandName = "Delete" Then
            Dim lid As Integer = e.Item.OwnerTableView.DataKeyValues(e.Item.ItemIndex)("License_To_Operate_ID")
            Dim uid As Integer
            If Request.QueryString("EmployeeID") = "" Or Request.QueryString("EmployeeID") = 0 Then
                uid = HttpContext.Current.Session("tmpUserID").ToString
            Else
                uid = GetUserIDbyEmployeeID(Request.QueryString("EmployeeID")).ToString
            End If
            Dim rec2 = (From p In dc.db_Employee_Licenses Where p.UserID = uid And p.License_To_Operate_ID = lid).FirstOrDefault
            If Not IsNothing(rec2) Then
                dc.db_Employee_Licenses.DeleteOnSubmit(rec2)
                dc.SubmitChanges()
            End If
            RadGrid_License.DataBind()
        End If
        'End If
 
        dc.Dispose()
    End If
End Sub
Private Sub RadGrid_License_ItemDataBound(ByVal sender As Object, ByVal e As Telerik.Web.UI.GridItemEventArgs) Handles RadGrid_License.ItemDataBound
    'If (TypeOf e.Item Is GridEditableItem AndAlso e.Item.IsInEditMode) Then
    '    Dim item As GridEditableItem = e.Item
    '    'access/modify the edit item template settings here
    '    Dim list As RadDropDownList = item.FindControl("rdl_license_type")
    '    'list.DataSource = Country_values
    '    'list.DataBind()
    '    If (Not HttpContext.Current.Session("updatedValue") Is Nothing) Then
    '        list.SelectedValue = 2
    '        'HttpContext.Current.Session("updatedValue")
    '    End If
    'ElseIf (TypeOf e.Item Is GridDataItem AndAlso Not e.Item.IsInEditMode AndAlso Page.IsPostBack) Then
    '    Dim item As GridDataItem = e.Item
    '    Dim label As Label = item.FindControl("Lb_License_ID")
 
    '    'update the label value
    '    label.Text = HttpContext.Current.Session("updatedValue")
    'End If
 
    If (TypeOf e.Item Is GridEditableItem AndAlso e.Item.IsInEditMode) Then
        Dim item As GridEditableItem = e.Item
        Dim ddl As RadDropDownList = item.FindControl("rdl_license_type")
        ddl.SelectedValue = DataBinder.Eval(e.Item.DataItem, "License_ID").ToString
    End If
 
 
End Sub
 
Protected Sub RadGrid_License_PreRender(ByVal sender As Object, ByVal e As System.EventArgs) Handles RadGrid_License.PreRender
    If (Not Page.IsPostBack) Then
        RadGrid_License.EditIndexes.Add(0)
        RadGrid_License.Rebind()
    End If
End Sub
 
Protected Sub RadGrid_License_ItemDeleted(ByVal source As Object, ByVal e As Telerik.Web.UI.GridDeletedEventArgs) Handles RadGrid_License.ItemDeleted
    If Not e.Exception Is Nothing Then
        e.ExceptionHandled = True
        'DisplayMessage(True, "Employee " + e.Item.OwnerTableView.DataKeyValues(e.Item.ItemIndex)("EmployeeID").ToString() + " cannot be deleted. Reason: " + e.Exception.Message)
    Else
        'DisplayMessage(False, "Employee " + e.Item.OwnerTableView.DataKeyValues(e.Item.ItemIndex)("EmployeeID").ToString() + " deleted")
    End If
End Sub
 
Protected Sub RadGrid_License_ItemUpdated(ByVal source As Object, ByVal e As Telerik.Web.UI.GridUpdatedEventArgs) Handles RadGrid_License.ItemUpdated
    If Not e.Exception Is Nothing Then
        e.KeepInEditMode = True
        e.ExceptionHandled = True
        'DisplayMessage(True, "Employee " + e.Item.OwnerTableView.DataKeyValues(e.Item.ItemIndex)("EmployeeID").ToString() + " cannot be updated. Reason: " + e.Exception.Message)
 
    Else
 
        'DisplayMessage(False, "Employee " + e.Item.OwnerTableView.DataKeyValues(e.Item.ItemIndex)("EmployeeID").ToString() + " updated")
        'If (TypeOf e.Item Is GridEditableItem AndAlso e.Item.IsInEditMode) Then
        '    Dim item As GridEditableItem = e.Item
        '    Dim dc As New dcLRDBDataContext
        '    Dim rec = (From p In dc.db_Employee_Licenses Where p.License_To_Operate_ID = e.Item.OwnerTableView.DataKeyValues(e.Item.ItemIndex)("License_To_Operate_ID").ToString()).FirstOrDefault
 
        '    Dim ddl As RadDropDownList = item.FindControl("rdl_license_type")
        '    'ddl.SelectedValue = DataBinder.Eval(e.Item.DataItem, "License_ID").ToString
 
        '    Dim tb_License_Number As TextBox = item.FindControl("tb_License_Number")
        '    Dim tb_License_Issuer As TextBox = item.FindControl("tb_License_Issuer")
        '    Dim IssueDatePicker As RadDatePicker = item.FindControl("IssueDatePicker")
        '    Dim RadDatePicker_ValidFrom As RadDatePicker = item.FindControl("RadDatePicker_ValidFrom")
        '    Dim RadDatePicker_ValidTill As RadDatePicker = item.FindControl("RadDatePicker_ValidTill")
 
        '    If Not rec Is Nothing Then
        '        rec.License_Number = tb_License_Number.Text
        '        rec.License_Issuer = tb_License_Issuer.Text
        '        rec.License_ID = ddl.SelectedValue
        '        rec.Valid_From = RadDatePicker_ValidFrom.SelectedDate
        '        rec.Valid_Till = RadDatePicker_ValidTill.SelectedDate
        '        rec.Issue_date = IssueDatePicker.SelectedDate
        '        dc.SubmitChanges()
        '    End If
        '    dc.Dispose()
        'End If
    End If
End Sub
 
Protected Sub RadGrid_License_ItemInserted(ByVal source As Object, ByVal e As Telerik.Web.UI.GridInsertedEventArgs) Handles RadGrid_License.ItemInserted
    If Not e.Exception Is Nothing Then
        e.ExceptionHandled = True
        e.KeepInInsertMode = True
        'DisplayMessage(True, "Employee cannot be inserted. Reason: " + e.Exception.Message)
    Else
        'DisplayMessage(False, "Employee inserted")
    End If
End Sub

Joe
Top achievements
Rank 1
 answered on 24 Jul 2013
Narrow your results
Selected tags
Tags
+? more
Top users last month
Chester
Top achievements
Rank 1
Iron
Simon
Top achievements
Rank 1
Iron
Douglas
Top achievements
Rank 2
Iron
Iron
SUNIL
Top achievements
Rank 3
Iron
Iron
Iron
Marco
Top achievements
Rank 3
Iron
Iron
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Chester
Top achievements
Rank 1
Iron
Simon
Top achievements
Rank 1
Iron
Douglas
Top achievements
Rank 2
Iron
Iron
SUNIL
Top achievements
Rank 3
Iron
Iron
Iron
Marco
Top achievements
Rank 3
Iron
Iron
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?