This is a migrated thread and some comments may be shown as answers.

Error while using web user control with rad grid

4 Answers 125 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Ajay
Top achievements
Rank 1
Ajay asked on 08 Feb 2011, 09:15 PM
hi we are using web user control with rad grid and getting following error is there any way to resolve this error
<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="EditStudentDetails.ascx.cs"
    Inherits="AdminPortal.Admin.WebUserControl1" %>
<table>
    <tr>
        <td align="right" colspan="2">
            <asp:Button ID="btnUpdate" Text="Update" runat="server" CommandName="Update" Visible='<%# Not (TypeOf DataItem Is Telerik.Web.UI.GridInsertionObject) %>'>
            </asp:Button>
            <asp:Button ID="btnInsert" Text="Insert" runat="server" CommandName="PerformInsert"
                Visible='<%# (TypeOf DataItem Is Telerik.Web.UI.GridInsertionObject) %>'></asp:Button>
              
            <asp:Button ID="btnCancel" Text="Cancel" runat="server" CausesValidation="False"
                CommandName="Cancel"></asp:Button>
        </td>
    </tr>
</table>
<%@ Page Title="" Language="C#" MasterPageFile="~/Admin/AdminMaster.Master" AutoEventWireup="true"
    CodeBehind="StudentDetails.aspx.cs" Inherits="AdminPortal.Admin.StudentDetails" %>
 
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <%--<telerik:RadScriptManager ID="RadScriptManager1" runat="server" />--%>
    <!-- content start -->
    <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
        <AjaxSettings>
            <telerik:AjaxSetting AjaxControlID="RadGrid1">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="RadGrid1" LoadingPanelID="RadAjaxLoadingPanel1" />
                </UpdatedControls>
            </telerik:AjaxSetting>
        </AjaxSettings>
    </telerik:RadAjaxManager>
    <telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" runat="server" />
    <telerik:RadCodeBlock runat="server" ID="radCodeBlock">
        <script type="text/javascript">
            function showFilterItem() {
                $find('<%=RadGrid1.ClientID %>').get_masterTableView().showFilterItem();
            }
            function hideFilterItem() {
                $find('<%=RadGrid1.ClientID %>').get_masterTableView().hideFilterItem();
            }
 
 
 
 
            function RowDblClick(sender, eventArgs) {
                sender.get_masterTableView().editItem(eventArgs.get_itemIndexHierarchical());
            }
        
        </script>
    </telerik:RadCodeBlock>
    <telerik:RadGrid ID="RadGrid1" runat="server" GridLines="None" AllowPaging="True"
        DataSourceID="EntityDataSource1" AllowSorting="True" AutoGenerateColumns="False"
        ShowStatusBar="true" CssClass="RadGrid">
        <MasterTableView Width="100%" DataKeyNames="StudentID">
            <Columns>
                <telerik:GridEditCommandColumn UniqueName="EditCommandColumn">
                </telerik:GridEditCommandColumn>
                <telerik:GridBoundColumn DataField="StudentID" DataType="System.Int32" HeaderText="StudentID"
                    ReadOnly="True" SortExpression="StudentID" UniqueName="StudentID" Visible="false">
                </telerik:GridBoundColumn>
                <telerik:GridBoundColumn DataField="StudentName" HeaderText="StudentName" SortExpression="StudentName"
                    UniqueName="StudentName">
                </telerik:GridBoundColumn>
                <telerik:GridBoundColumn DataField="ParentsName" HeaderText="ParentsName" SortExpression="ParentsName"
                    UniqueName="ParentsName">
                </telerik:GridBoundColumn>
                <telerik:GridBoundColumn DataField="Gender" HeaderText="Gender" SortExpression="Gender"
                    UniqueName="Gender" Visible="false">
                </telerik:GridBoundColumn>
                <telerik:GridBoundColumn DataField="EmailId" HeaderText="EmailId" SortExpression="EmailId"
                    UniqueName="EmailId">
                </telerik:GridBoundColumn>
                <telerik:GridBoundColumn DataField="PhoneNumber" HeaderText="PhoneNumber" SortExpression="PhoneNumber"
                    UniqueName="PhoneNumber">
                </telerik:GridBoundColumn>
                <telerik:GridBoundColumn DataField="MobileNumber" HeaderText="MobileNumber" SortExpression="MobileNumber"
                    UniqueName="MobileNumber">
                </telerik:GridBoundColumn>
                <telerik:GridBoundColumn DataField="Subject" HeaderText="Subject" SortExpression="Subject"
                    UniqueName="Subject" Visible="false">
                </telerik:GridBoundColumn>
                <telerik:GridBoundColumn DataField="TimeZone" HeaderText="TimeZone" SortExpression="TimeZone"
                    UniqueName="TimeZone">
                </telerik:GridBoundColumn>
                <telerik:GridBoundColumn DataField="Address" HeaderText="Address" SortExpression="Address"
                    UniqueName="Address">
                </telerik:GridBoundColumn>
                <telerik:GridBoundColumn DataField="Country" HeaderText="Country" SortExpression="Country"
                    UniqueName="Country" Visible="false">
                </telerik:GridBoundColumn>
                <telerik:GridBoundColumn DataField="State" HeaderText="State" SortExpression="State"
                    UniqueName="State" Visible="false">
                </telerik:GridBoundColumn>
                <telerik:GridBoundColumn DataField="City" HeaderText="City" SortExpression="City"
                    UniqueName="City" Visible="false">
                </telerik:GridBoundColumn>
                <telerik:GridBoundColumn DataField="ZipCode" HeaderText="ZipCode" SortExpression="ZipCode"
                    UniqueName="ZipCode" Visible="false">
                </telerik:GridBoundColumn>
                <telerik:GridBoundColumn DataField="SkypeId" HeaderText="SkypeId" SortExpression="SkypeId"
                    UniqueName="SkypeId" Visible="false">
                </telerik:GridBoundColumn>
                <telerik:GridBoundColumn DataField="Status" HeaderText="Status" SortExpression="Status"
                    UniqueName="Status" Visible="false">
                </telerik:GridBoundColumn>
                <telerik:GridButtonColumn UniqueName="DeleteColumn" Text="Delete" CommandName="Delete" />
            </Columns>
            <EditFormSettings UserControlName="EditStudentDetails.ascx" EditFormType="WebUserControl">
                <EditColumn UniqueName="EditCommandColumn1">
                </EditColumn>
            </EditFormSettings>
            <ExpandCollapseColumn ButtonType="ImageButton" Visible="False" UniqueName="ExpandColumn">
                <HeaderStyle Width="19px"></HeaderStyle>
            </ExpandCollapseColumn>
        </MasterTableView>
        <ClientSettings>
            <ClientEvents OnRowDblClick="RowDblClick" />
        </ClientSettings>
    </telerik:RadGrid>
    <%--<telerik:RadGrid AutoGenerateColumns="false" ID="RadGrid1" DataSourceID="EntityDataSource1"
        AllowFilteringByColumn="True" AllowSorting="True" CssClass="RadGrid" GridLines="None"
        AllowPaging="True" PageSize="20" runat="server" EnableLinqExpressions="false"
        Width="500px" OnItemDeleted="RadGrid1_ItemDeleted" OnItemUpdated="RadGrid1_ItemUpdated"
        OnItemCommand="RadGrid1_ItemCommand" OnPreRender="RadGrid1_PreRender">
        <PagerStyle Mode="NextPrevAndNumeric" ShowPagerText="true" />
        <GroupingSettings CaseSensitive="false" />
        <MasterTableView AutoGenerateColumns="false" AllowFilteringByColumn="True" TableLayout="Auto"
            DataKeyNames="StudentID" DataSourceID="EntityDataSource1" EditMode="InPlace"
            ShowFooter="true">
            <CommandItemSettings ExportToPdfText="Export to Pdf"></CommandItemSettings>
            <Columns>
               <telerik:GridEditCommandColumn UniqueName="EditCommandColumn">
                </telerik:GridEditCommandColumn>
                <telerik:GridButtonColumn UniqueName="DeleteColumn" CommandName="Delete" ButtonType="ImageButton" /> 
                <telerik:GridEditCommandColumn>
                </telerik:GridEditCommandColumn>
                <telerik:GridBoundColumn DataField="StudentID" DataType="System.Int32" HeaderText="StudentID"
                    ReadOnly="True" SortExpression="StudentID" UniqueName="StudentID" Visible="false">
                </telerik:GridBoundColumn>
                <telerik:GridBoundColumn DataField="StudentName" HeaderText="StudentName" SortExpression="StudentName"
                    UniqueName="StudentName">
                </telerik:GridBoundColumn>
                <telerik:GridBoundColumn DataField="ParentsName" HeaderText="ParentsName" SortExpression="ParentsName"
                    UniqueName="ParentsName">
                </telerik:GridBoundColumn>
                <telerik:GridBoundColumn DataField="Gender" HeaderText="Gender" SortExpression="Gender"
                    UniqueName="Gender" Visible="false">
                </telerik:GridBoundColumn>
                <telerik:GridBoundColumn DataField="EmailId" HeaderText="EmailId" SortExpression="EmailId"
                    UniqueName="EmailId">
                </telerik:GridBoundColumn>
                <telerik:GridBoundColumn DataField="PhoneNumber" HeaderText="PhoneNumber" SortExpression="PhoneNumber"
                    UniqueName="PhoneNumber">
                </telerik:GridBoundColumn>
                <telerik:GridBoundColumn DataField="MobileNumber" HeaderText="MobileNumber" SortExpression="MobileNumber"
                    UniqueName="MobileNumber">
                </telerik:GridBoundColumn>
                <telerik:GridBoundColumn DataField="Subject" HeaderText="Subject" SortExpression="Subject"
                    UniqueName="Subject" Visible="false">
                </telerik:GridBoundColumn>
                <telerik:GridBoundColumn DataField="TimeZone" HeaderText="TimeZone" SortExpression="TimeZone"
                    UniqueName="TimeZone">
                </telerik:GridBoundColumn>
                <telerik:GridBoundColumn DataField="Address" HeaderText="Address" SortExpression="Address"
                    UniqueName="Address">
                </telerik:GridBoundColumn>
                <telerik:GridBoundColumn DataField="Country" HeaderText="Country" SortExpression="Country"
                    UniqueName="Country" Visible="false">
                </telerik:GridBoundColumn>
                <telerik:GridBoundColumn DataField="State" HeaderText="State" SortExpression="State"
                    UniqueName="State" Visible="false">
                </telerik:GridBoundColumn>
                <telerik:GridBoundColumn DataField="City" HeaderText="City" SortExpression="City"
                    UniqueName="City" Visible="false">
                </telerik:GridBoundColumn>
                <telerik:GridBoundColumn DataField="ZipCode" HeaderText="ZipCode" SortExpression="ZipCode"
                    UniqueName="ZipCode" Visible="false">
                </telerik:GridBoundColumn>
                <telerik:GridBoundColumn DataField="SkypeId" HeaderText="SkypeId" SortExpression="SkypeId"
                    UniqueName="SkypeId" Visible="false">
                </telerik:GridBoundColumn>
                <telerik:GridBoundColumn DataField="Status" HeaderText="Status" SortExpression="Status"
                    UniqueName="Status" Visible="false">
                </telerik:GridBoundColumn>
            </Columns>
            <EditFormSettings EditFormType="Template">
                <FormTemplate>
                    <table id="Table2" cellspacing="2" cellpadding="1" width="100%" border="0" rules="none"
                        style="border-collapse: collapse; background: white;">
                        <tr class="EditFormHeader">
                            <td colspan="2" style="font-size: small">
                                <b>Student Details</b>
                            </td>
                        </tr>
                        <tr>
                            <td>
                                <table id="Table3" cellspacing="1" cellpadding="1" width="250" border="0" class="module">
                                    <tr>
                                        <td>
                                        </td>
                                        <td>
                                        </td>
                                    </tr>
                                    <tr>
                                        <td>
                                            Country:
                                        </td>
                                        <td>
                                            <asp:TextBox ID="TextBox7" runat="server" Text='<%# Bind("Country") %>'>
                                            </asp:TextBox>
                                        </td>
                                    </tr>
                                    <tr>
                                        <td>
                                            City:
                                        </td>
                                        <td>
                                            <asp:TextBox ID="TextBox8" runat="server" Text='<%# Bind("City") %>' TabIndex="1">
                                            </asp:TextBox>
                                        </td>
                                    </tr>
                                    <tr>
                                        <td>
                                            Region:
                                        </td>
                                        <td>
                                            <asp:TextBox ID="TextBox9" runat="server" Text='<%# Bind("State") %>' TabIndex="2">
                                            </asp:TextBox>
                                        </td>
                                    </tr>
                                    <tr>
                                        <td>
                                            Home Phone:
                                        </td>
                                        <td>
                                            <telerik:RadMaskedTextBox ID="HomePhoneBox" runat="server" SelectionOnFocus="SelectAll"
                                                Text='<%# Bind("PhoneNumber") %>' PromptChar="_" Width="300px" Mask="(###) ###-####"
                                                TabIndex="3">
                                            </telerik:RadMaskedTextBox>
                                        </td>
                                    </tr>
                                </table>
                            </td>
                            <td>
                                <table id="Table1" cellspacing="1" cellpadding="1" width="250" border="0" class="module">
                                    <tr>
                                        <td>
                                            Address:
                                        </td>
                                    </tr>
                                    <tr>
                                        <td>
                                            <asp:TextBox ID="TextBox6" Text='<%# Bind("Address") %>' runat="server" TextMode="MultiLine"
                                                Rows="2" Columns="40" TabIndex="6">
                                            </asp:TextBox>
                                        </td>
                                    </tr>
                                </table>
                            </td>
                        </tr>
                        <tr>
                            <td colspan="2">
                                <b>Personal Info:</b>
                            </td>
                        </tr>
                        <tr>
                            <td>
                                <table id="Table4" cellspacing="1" cellpadding="1" width="250" border="0" class="module">
                                    <tr>
                                        <td>
                                            Student Name:
                                        </td>
                                        <td>
                                            <asp:TextBox ID="TextBox2" Text='<%# Bind( "StudentName") %>' runat="server" TabIndex="8">
                                            </asp:TextBox>
                                        </td>
                                    </tr>
                                    <tr>
                                        <td>
                                            Parent Name:
                                        </td>
                                        <td>
                                            <asp:TextBox ID="TextBox3" Text='<%# Bind( "ParentsName") %>' runat="server" TabIndex="9">
                                            </asp:TextBox>
                                        </td>
                                    </tr>
                                </table>
                            </td>
                            <td>
                            </td>
                        </tr>
                        <tr>
                            <td align="right" colspan="2">
                                <asp:Button ID="btnUpdate" Text='<%# (Container is GridEditFormInsertItem) ? "Insert" : "Update" %>'
                                    runat="server" CommandName='<%# (Container is GridEditFormInsertItem) ? "PerformInsert" : "Update" %>'>
                                </asp:Button
                                <asp:Button ID="btnCancel" Text="Cancel" runat="server" CausesValidation="False"
                                    CommandName="Cancel"></asp:Button>
                            </td>
                        </tr>
                    </table>
                </FormTemplate>
            </EditFormSettings>
        </MasterTableView>
        <ClientSettings EnableRowHoverStyle="true">
            <Selecting AllowRowSelect="True" />
            <Scrolling AllowScroll="false" />
        </ClientSettings>
    </telerik:RadGrid>--%>
    <asp:EntityDataSource ID="EntityDataSource1" runat="server" ConnectionString="name=AdminPortalEntities"
        DefaultContainerName="AdminPortalEntities" EnableDelete="True" EnableFlattening="False"
        EnableUpdate="True" EntitySetName="StudentInfoes">
    </asp:EntityDataSource>
    <!-- content end -->
</asp:Content>

4 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 09 Feb 2011, 10:21 AM
Hello Ajay,

You are getting this error because you have writtem code in VB for the setting the Visibility for the Button in UserControl. Try the following code as described in this demo.
C#:
<asp:Button ID="btnUpdate" Text="Update" runat="server" CommandName="Update" Visible='<%# !(DataItem is Telerik.Web.UI.GridInsertionObject) %>'>
 </asp:Button>

Grid / User Control Edit Form

Thanks,
Princy.
0
Ajay
Top achievements
Rank 1
answered on 09 Feb 2011, 12:57 PM
Thanks for this quick reply.
now what i want is to have related combo boxes in form template.
example : contry--> state-->city
so can i handle this kind of functionality in edit form template.
0
Princy
Top achievements
Rank 2
answered on 10 Feb 2011, 07:00 AM
Hello Ajay,

You can add the comboboxes inside FormTemplate and interact with each other based on certain client or server side events as mentioned in this demo.
ComboBox / Related ComboBoxes
ASPX:
<FormTemplate>
    <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
    <asp:Button ID="GrdbtnGo" runat="server" CommandName="PerformInsert" Text="Update" />
    <telerik:RadComboBox ID="RadComboBox1" runat="server" Width="186px" DataSourceID="SqlDataSource1"
        DataTextField="EmployeeID" DataValueField="EmployeeID"  OnClientSelectedIndexChanging="LoadCountries" />
    <telerik:RadComboBox ID="RadComboBox2" runat="server" Width="186px" />
</FormTemplate>

Java Script:
<script type="text/javascript">
   function LoadCountries(combo, eventArqs) {
        .   .    .   .   .
          }
</script>

Thanks,
Princy.
0
Ajay
Top achievements
Rank 1
answered on 10 Feb 2011, 05:01 PM
how can i access controls in edititemevent and bind comboboxes in formtemplate

this is the code i am using
using System;
using System.Web.UI.WebControls;
using Telerik.Web.UI;
using System.Data;
using System.Data.Objects;
using AdminPortal.Admin;
using AdminPortal.Tutor;
using System.Linq;
using System.Collections.ObjectModel;
namespace AdminPortal.Admin
{
    public partial class StudentDetails : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            //check this conditon on every page.
            if (AdminInfo.CheckSession() == true)
            {
                if (!IsPostBack)
                {
 
                }
 
            }
            else
            {
                Response.Redirect(Constants.HOME_PAGE);
            }
        }
        public void GetData()
        {
 
 
        }
 
        protected void CbCountry1_SelectedIndexChanged(object sender, Telerik.Web.UI.RadComboBoxSelectedIndexChangedEventArgs e)
        {
 
        }
        protected void RadGrid1_NeedDataSource(object source, GridNeedDataSourceEventArgs e)
        {
            System.Collections.IList dt;
            using (AdminPortalEntities context = new AdminPortalEntities())
            {
 
                var t = from c in context.StudentInfoes
                        select new
                        {
                            c.StudentID,
                            c.Address,
                            c.City,
                            c.Country,
                            c.EmailId,
                            c.Gender,
                            c.ParentsName,
                            c.MobileNumber,
                            c.PhoneNumber,
                            c.SkypeId,
                            c.State,
                            c.Status,
                            c.StudentName,
                            c.Subject,
                            c.TimeZone,
                            c.ZipCode
                        };
 
                dt = t.ToList();
 
 
 
                //this.RadGrid1.DataBind();
 
            }
            this.RadGrid1.DataSource = dt;
        }
 
        protected void RadGrid1_DeleteCommand(object source, GridCommandEventArgs e)
        {
            //Get the GridDataItem of the RadGrid    
            GridDataItem item = (GridDataItem)e.Item;
            //Get the primary key value using the DataKeyValue.    
            string StudentID = item.OwnerTableView.DataKeyValues[item.ItemIndex]["StudentID"].ToString();
            try
            {
                //Open the SqlConnection    
 
 
            }
            catch (Exception ex)
            {
 
                e.Canceled = true;
            }
 
        }
        protected void RadGrid1_UpdateCommand(object source, GridCommandEventArgs e)
        {
            ////Get the GridEditableItem of the RadGrid    
            //GridEditableItem editedItem = e.Item as GridEditableItem;
            ////Get the primary key value using the DataKeyValue.    
            //string EmployeeID = editedItem.OwnerTableView.DataKeyValues[editedItem.ItemIndex]["EmployeeID"].ToString();
            ////Access the textbox from the edit form template and store the values in string variables.    
            //string LastName = (editedItem["LastName"].Controls[0] as TextBox).Text;
            //string FirstName = (editedItem["FirstName"].Controls[0] as TextBox).Text;
            //string Title = (editedItem["Title"].Controls[0] as TextBox).Text;
            //string Address = (editedItem["Address"].Controls[0] as TextBox).Text;
            //string City = (editedItem["City"].Controls[0] as TextBox).Text;
 
            try
            {
 
                if (e.CommandName == RadGrid.UpdateCommandName)
                {
                    if (e.Item is GridEditFormItem)
                    {
                        GridEditFormItem item = (GridEditFormItem)e.Item;
                        int StudentID = Convert.ToInt32(item.GetDataKeyValue("StudentID"));
                        if (StudentID != 0)
                        {
                            TextBox txtCategoryName =
                                (TextBox)item.FindControl("txtCategoryName");
                            TextBox txtDescription =
                                (TextBox)item.FindControl("txtDescription");
 
 
 
                            RadGrid1.Rebind();
                        }
                    }
                }
 
            }
            catch (Exception ex)
            {
 
                e.Canceled = true;
            }
 
        }
 
        protected void RadGrid1_EditCommand(object source, GridCommandEventArgs e)
        {
            try
            {
 
                if (e.CommandName == RadGrid.EditCommandName)
                {
                    if (e.Item is GridEditableItem)
                    {
                        GridEditableItem item = (GridEditableItem)e.Item;
                        int StudentID = Convert.ToInt32(item.GetDataKeyValue("StudentID"));
                        if (StudentID != 0)
                        {
                            RadComboBox rcbCountry =
                                (RadComboBox)item.FindControl(Constants.RadComboBoxCountry);
 
 
                            RadGrid1.Rebind();
                        }
                    }
                }
 
            }
            catch (Exception ex)
            {
 
                e.Canceled = true;
            }
 
        }
        protected void RadGrid1_ItemCommand(object source, GridCommandEventArgs e)
        {
 
 
 
        }
    }
}
<%@ Page Title="" Language="C#" MasterPageFile="~/Admin/AdminMaster.Master" AutoEventWireup="true"
    CodeBehind="StudentDetails.aspx.cs" Inherits="AdminPortal.Admin.StudentDetails" %>
 
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <!-- content start -->
    <telerik:RadCodeBlock ID="RadCodeBlock1" runat="server">
        <script type="text/javascript">
            function RowDblClick(sender, eventArgs) {
                sender.get_masterTableView().editItem(eventArgs.get_itemIndexHierarchical());
            }
            function showFilterItem() {
                $find('<%=RadGrid1.ClientID %>').get_masterTableView().showFilterItem();
            }
            function hideFilterItem() {
                $find('<%=RadGrid1.ClientID %>').get_masterTableView().hideFilterItem();
            }
        </script>
    </telerik:RadCodeBlock>
    <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
        <AjaxSettings>
            <telerik:AjaxSetting AjaxControlID="RadGrid1">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="RadGrid1" LoadingPanelID="RadAjaxLoadingPanel1" />
                </UpdatedControls>
            </telerik:AjaxSetting>
        </AjaxSettings>
    </telerik:RadAjaxManager>
    <telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" runat="server" />
    <telerik:RadAjaxPanel runat="server" ID="RadAjaxPanel1">
        <telerik:RadGrid ID="RadGrid1" runat="server" GridLines="None" AllowPaging="True"
            AllowSorting="True" AutoGenerateColumns="False" ShowStatusBar="true" CssClass="RadGrid"
            AllowFilteringByColumn="True" OnNeedDataSource="RadGrid1_NeedDataSource" OnDeleteCommand="RadGrid1_DeleteCommand"
            OnUpdateCommand="RadGrid1_UpdateCommand" OnItemCommand="RadGrid1_ItemCommand" OnEditCommand="RadGrid1_EditCommand">
            <MasterTableView Width="100%" DataKeyNames="StudentID">
                <Columns>
                    <telerik:GridButtonColumn UniqueName="EditColumn" Text="Edit" CommandName="Edit" />
                    <telerik:GridBoundColumn DataField="StudentID" DataType="System.Int32" HeaderText="StudentID"
                        ReadOnly="True" SortExpression="StudentID" UniqueName="StudentID" Visible="false">
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn DataField="StudentName" HeaderText="Student Name" SortExpression="StudentName"
                        UniqueName="StudentName">
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn DataField="ParentsName" HeaderText="Parent Name" SortExpression="ParentsName"
                        UniqueName="ParentsName">
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn DataField="Gender" HeaderText="Gender" SortExpression="Gender"
                        UniqueName="Gender" Visible="false">
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn DataField="EmailId" HeaderText="EmailId" SortExpression="EmailId"
                        UniqueName="EmailId">
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn DataField="PhoneNumber" HeaderText="Phone Number" SortExpression="PhoneNumber"
                        UniqueName="PhoneNumber">
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn DataField="MobileNumber" HeaderText="Mobile Number" SortExpression="MobileNumber"
                        UniqueName="MobileNumber">
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn DataField="Subject" HeaderText="Subject" SortExpression="Subject"
                        UniqueName="Subject" Visible="false">
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn DataField="TimeZone" HeaderText="Time Zone" SortExpression="TimeZone"
                        UniqueName="TimeZone">
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn DataField="Address" HeaderText="Address" SortExpression="Address"
                        UniqueName="Address">
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn DataField="Country" HeaderText="Country" SortExpression="Country"
                        UniqueName="Country" Visible="false">
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn DataField="State" HeaderText="State" SortExpression="State"
                        UniqueName="State" Visible="false">
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn DataField="City" HeaderText="City" SortExpression="City"
                        UniqueName="City" Visible="false">
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn DataField="ZipCode" HeaderText="ZipCode" SortExpression="ZipCode"
                        UniqueName="ZipCode" Visible="false">
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn DataField="SkypeId" HeaderText="SkypeId" SortExpression="SkypeId"
                        UniqueName="SkypeId" Visible="false">
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn DataField="Status" HeaderText="Status" SortExpression="Status"
                        UniqueName="Status" Visible="true">
                    </telerik:GridBoundColumn>
                    <telerik:GridButtonColumn UniqueName="DeleteColumn" Text="Delete" CommandName="Delete" />
                </Columns>
                <EditFormSettings EditFormType="Template">
                    <FormTemplate>
                        <table class="style6">
                            <tr>
                                <td class="style8">
                                    <asp:Label ID="Label58" runat="server" Text="Student Name"></asp:Label>
                                      <span style="color: Red; text-align: left; font-size: small; font-family: Book Antiqua;
                                        font-weight: normal;">* </span>
                                </td>
                                <td class="style9">
                                    <telerik:RadTextBox ID="txtStudentName" runat="server" EmptyMessage="Student Name"
                                        Width="225px" Text='<%# Bind( "StudentName") %>'>
                                    </telerik:RadTextBox>
                                </td>
                                <td class="style8">
                                    <asp:Label ID="Label59" runat="server" Text="Parents Name"></asp:Label>
                                      <span style="color: Red; text-align: left; font-size: small; font-family: Book Antiqua;
                                        font-weight: normal;">* </span>
                                </td>
                                <td class="style10">
                                    <telerik:RadTextBox ID="txtParentName" runat="server" EmptyMessage="Parents Name"
                                        Width="225px" Text='<%# Bind( "ParentsName") %>'>
                                    </telerik:RadTextBox>
                                </td>
                                <td>
                                      
                                </td>
                            </tr>
                            <tr>
                                <td class="style8">
                                    <asp:Label ID="Label2" runat="server" Text="Gender"></asp:Label>
                                    <span style="color: Red; text-align: left; font-size: small; font-family: Book Antiqua;
                                        font-weight: normal;">* </span>
                                </td>
                                <td class="style9">
                                    <telerik:RadComboBox ID="CbGender" runat="server" Width="225px">
                                        <Items>
                                            <telerik:RadComboBoxItem runat="server" Selected="True" Text="Select Gender" Value="Select"
                                                Owner="CbGender" />
                                            <telerik:RadComboBoxItem runat="server" Owner="CbGender" Text="Male" Value="Male" />
                                            <telerik:RadComboBoxItem runat="server" Owner="CbGender" Text="Female" Value="Female" />
                                        </Items>
                                    </telerik:RadComboBox>
                                </td>
                                <td class="style8">
                                    <asp:Label ID="Label7" runat="server" Text="Email Id"></asp:Label>
                                      <span style="color: Red; text-align: left; font-size: small; font-family: Book Antiqua;
                                        font-weight: normal;">* </span>
                                </td>
                                <td class="style10">
                                    <asp:TextBox ID="txtEmailId" runat="server" Width="225px" Text='<%# Bind( "EmailID") %>'> </asp:TextBox>
                                </td>
                                <td>
                                      
                                </td>
                            </tr>
                            <tr>
                                <td class="style8">
                                    <asp:Label ID="Label3" runat="server" Text="Home Phone"></asp:Label>
                                      
                                </td>
                                <td class="style9">
                                    <telerik:RadMaskedTextBox ID="HomePhoneBox" runat="server" SelectionOnFocus="SelectAll"
                                        Text='<%# Bind("PhoneNumber") %>' PromptChar="_" Mask="(###) ###-####" TabIndex="6">
                                    </telerik:RadMaskedTextBox>
                                </td>
                                <td class="style8">
                                    <asp:Label ID="Label45" runat="server" Text="Mobile No"></asp:Label>
                                      <span style="color: Red; text-align: left; font-size: small; font-family: Book Antiqua;
                                        font-weight: normal;">* </span>
                                </td>
                                <td class="style10">
                                    <telerik:RadMaskedTextBox ID="MobilePhoneBox" runat="server" SelectionOnFocus="SelectAll"
                                        Text='<%# Bind("MobileNumber") %>' PromptChar="_" Mask="(###) ###-####" TabIndex="6">
                                    </telerik:RadMaskedTextBox>
                                </td>
                                <td>
                                      
                                </td>
                            </tr>
                            <tr>
                                <td class="style8">
                                    <asp:Label ID="Label43" runat="server" Text="Subjects"></asp:Label>
                                </td>
                                <td class="style9">
                                    <telerik:RadComboBox ID="CbSubject" runat="server" Width="225px" EmptyMessage="Select Subject">
                                    </telerik:RadComboBox>
                                </td>
                                <td class="style8">
                                    <asp:Label ID="Label44" runat="server" Text="Time Zone"></asp:Label>
                                      <span style="color: Red; text-align: left; font-size: small; font-family: Book Antiqua;
                                        font-weight: normal;">* </span>
                                </td>
                                <td class="style10">
                                    <telerik:RadComboBox ID="CbTimeZone" runat="server" Width="225px" EmptyMessage="Select Timezone">
                                    </telerik:RadComboBox>
                                </td>
                                <td>
                                      
                                </td>
                            </tr>
                            <tr>
                                <td class="style8">
                                    <asp:Label ID="Label47" runat="server" Text="Address"></asp:Label>
                                      <span style="color: Red; text-align: left; font-size: small; font-family: Book Antiqua;
                                        font-weight: normal;">* </span>
                                </td>
                                <td class="style9">
                                    <telerik:RadTextBox ID="txtAddress" runat="server" EmptyMessage="Address" Height="26px"
                                        TextMode="MultiLine" Width="225px" Text='<%# Bind( "Address") %>'>
                                    </telerik:RadTextBox>
                                </td>
                                <td class="style8">
                                    <asp:Label ID="Label52" runat="server" Text="Country"></asp:Label>
                                      <span style="color: Red; text-align: left; font-size: small; font-family: Book Antiqua;
                                        font-weight: normal;">* </span>
                                </td>
                                <td class="style10">
                                    <telerik:RadComboBox ID="cbCountry" runat="server" Width="225px" OnSelectedIndexChanged="CbCountry1_SelectedIndexChanged"
                                        AutoPostBack="True" EmptyMessage="Select Country">
                                    </telerik:RadComboBox>
                                </td>
                                <td>
                                      
                                </td>
                            </tr>
                            <tr>
                                <td class="style8">
                                    <asp:Label ID="Label53" runat="server" Text="State"></asp:Label>
                                </td>
                                <td class="style9">
                                    <telerik:RadComboBox ID="CbState" runat="server" Width="225px" EmptyMessage="Select State">
                                    </telerik:RadComboBox>
                                </td>
                                <td class="style8">
                                     <asp:Label ID="Label54" runat="server" Text="City"></asp:Label>
                                     <span style="color: Red; text-align: left; font-size: small; font-family: Book Antiqua;
                                        font-weight: normal;">* </span>
                                </td>
                                <td class="style10">
                                    <telerik:RadTextBox ID="txtCity" runat="server" EmptyMessage="Enter City" Width="225px"
                                        Text='<%# Bind( "City") %>'>
                                    </telerik:RadTextBox>
                                </td>
                                <td>
                                      
                                </td>
                            </tr>
                            <tr>
                                <td class="style8">
                                    <asp:Label ID="Label55" runat="server" Text="Zip Code"></asp:Label>
                                      
                                </td>
                                <td class="style9">
                                    <%--<asp:TextBox ID="txtZipCode" runat="server" Width="225px"></asp:TextBox>--%>
                                    <telerik:RadMaskedTextBox ID="txtZipCode" runat="server" PromptChar="-" Mask="#####-####"
                                        Text='<%# Bind( "ZipCode") %>'>
                                    </telerik:RadMaskedTextBox>
                                </td>
                                <td class="style8">
                                    <asp:Label ID="Label56" runat="server" Text="Skype Id"></asp:Label>
                                </td>
                                <td class="style10">
                                    <telerik:RadTextBox ID="txtSkyprid" runat="server" EmptyMessage="Skype Id" Width="225px"
                                        Text='<%# Bind( "SkypeId") %>'>
                                    </telerik:RadTextBox>
                                </td>
                                <td>
                                      
                                </td>
                                <td>
                                      
                                </td>
                            </tr>
                            <tr>
                                <td class="style8">
                                      
                                </td>
                                <td class="style9" colspan="3">
                                          
                                    <asp:Label ID="lblErrormsg" runat="server" ForeColor="Red" Text=" "></asp:Label>
                                </td>
                                <td>
                                      
                                </td>
                            </tr>
                            <tr>
                                <td class="style13">
                                </td>
                                <td class="style14">
                                    <telerik:RadInputManager ID="RadInputManager1" runat="server">
                                        <telerik:RegExpTextBoxSetting BehaviorID="RagExpBehavior1" EmptyMessage="EmailId"
                                            ErrorMessage="jonh@gmail.com" Validation-IsRequired="true" ValidationExpression="^\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$">
                                            <TargetControls>
                                                <telerik:TargetInput ControlID="txtEmailId" />
                                            </TargetControls>
                                        </telerik:RegExpTextBoxSetting>
                                        <%--       <telerik:RegExpTextBoxSetting BehaviorID="RagExpBehavior2" EmptyMessage="Enter Phone Number here"
                                                ErrorMessage="Enter Correct Number (222) 222-2222)" Validation-IsRequired="false"
                                                ValidationExpression="((\(\d{3}\) ?)|(\d{3}-))?\d{3}-\d{4}">
                                                <TargetControls>
                                                    <telerik:TargetInput ControlID="txtPhoneNumber" />
                                                </TargetControls>
                                            </telerik:RegExpTextBoxSetting>--%>
                                        <telerik:RegExpTextBoxSetting BehaviorID="RagExpBehavior3" EmptyMessage="Enter Mobile Number here"
                                            ErrorMessage="Enter 10 digit Mobile Number" Validation-IsRequired="true" ValidationExpression="\d{10}">
                                            <TargetControls>
                                                <telerik:TargetInput ControlID="txtMobileNumber" />
                                            </TargetControls>
                                        </telerik:RegExpTextBoxSetting>
                                        <%--  <telerik:RegExpTextBoxSetting BehaviorID="RagExpBehavior4" EmptyMessage="Enter ZipCode here"
                                                ErrorMessage="Enter ZipCode 22222(-2222)" Validation-IsRequired="true" ValidationExpression="\d{5}(-\d{4})?">
                                                <TargetControls>
                                                    <telerik:TargetInput ControlID="txtZipCode" />
                                                </TargetControls>
                                            </telerik:RegExpTextBoxSetting>--%>
                                    </telerik:RadInputManager>
                                </td>
                                <td class="style15">
                                    <telerik:RadButton ID="RadButton4" runat="server" Skin="Web20" Text="Clear" Height="22px"
                                        Width="65px" CausesValidation="False">
                                    </telerik:RadButton>
                                </td>
                                <td class="style16">
                                      
                                </td>
                            </tr>
                        </table>
                    </FormTemplate>
                </EditFormSettings>
                <ExpandCollapseColumn ButtonType="ImageButton" Visible="False" UniqueName="ExpandColumn">
                    <HeaderStyle Width="19px"></HeaderStyle>
                </ExpandCollapseColumn>
            </MasterTableView>
            <ClientSettings>
                <ClientEvents OnRowDblClick="RowDblClick" />
                 
            </ClientSettings>
        </telerik:RadGrid>
    </telerik:RadAjaxPanel>
    <!-- content end -->
</asp:Content>
Tags
Grid
Asked by
Ajay
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Ajay
Top achievements
Rank 1
Share this question
or