Telerik Forums
UI for ASP.NET AJAX Forum
1 answer
142 views

Requirements

RadControls version

 

                                RadControls  for  ASP.NET  AJAX  all versions

 

.NET version                                              2.0 and Later

 

Visual Studio version                                                        2005 and later

 

programming language                                                    c#

 

browser support

all browsers supported by RadControls


 


PROJECT DESCRIPTION

This is a simple code which deals with using filtertemplate in the radgrid with grid being binded from the code behind using the Needdatasource event and the comboboxes being loaded using the sqldatasource
<telerik:RadScriptManager ID="RadScriptManager1" runat="server">
        </telerik:RadScriptManager>
        <telerik:RadGrid ID="RadGrid1" runat="server" AutoGenerateColumns="False" 
            GridLines="None" onneeddatasource="RadGrid1_NeedDataSource" 
            AllowFilteringByColumn="True" AllowPaging="True" AllowSorting="True">
<MasterTableView>
<RowIndicatorColumn>
<HeaderStyle Width="20px"></HeaderStyle>
</RowIndicatorColumn>
  
<ExpandCollapseColumn>
<HeaderStyle Width="20px"></HeaderStyle>
</ExpandCollapseColumn>
    <Columns>
        <telerik:GridBoundColumn DataField="CountryID" HeaderText="MCountryID" 
            UniqueName="column">
        </telerik:GridBoundColumn>
        <telerik:GridBoundColumn DataField="CountryName" FilterListOptions ="VaryByDataType" HeaderText="CountryName" 
            UniqueName="CountryName" CurrentFilterFunction="EqualTo">
            <FilterTemplate>
                <telerik:RadComboBox ID="RadComboBox1" AppendDataBoundItems="true" SelectedValue='<%# ((GridItem)Container).OwnerTableView.GetColumn("CountryName").CurrentFilterValue %>'
DataSourceID="SqlDataSource1" 
                    DataTextField="CountryName" DataValueField="CountryName" runat="server" 
                    AutoPostBack="True"  Filter="Contains" MarkFirstMatch="True" OnClientSelectedIndexChanged="CountryIndexChanged">
                    <Items>
                           <telerik:RadComboBoxItem Text="All" />
                    </Items>
  
                </telerik:RadComboBox>
                  <telerik:RadScriptBlock ID="RadScriptBlock3" runat="server">
  
                                <script type="text/javascript">
                                    function CountryIndexChanged(sender, args) {
                                        var tableView = $find("<%# ((GridItem)Container).OwnerTableView.ClientID %>");
                                        tableView.filter("CountryName", args.get_item().get_value(), "EqualTo");
                                    }
                                </script>
  
                            </telerik:RadScriptBlock>
  
            </FilterTemplate>
        </telerik:GridBoundColumn>
        <telerik:GridBoundColumn DataField="CodeX2" HeaderText="CodeX2" 
            UniqueName="CodeX2"  CurrentFilterFunction="EqualTo" ShowFilterIcon="false">
        <FilterTemplate>
            <telerik:RadComboBox ID="RadComboBox2" DataSourceID="SqlDataSource1" SelectedValue='<%# ((GridItem)Container).OwnerTableView.GetColumn("CodeX2").CurrentFilterValue %>'  AppendDataBoundItems="true" DataTextField="CodeX2" OnClientSelectedIndexChanged="CodeX2IndexChanged" DataValueField="CodeX2" runat="server">
            </telerik:RadComboBox>
        <telerik:RadScriptBlock ID="RadScriptBlock5" runat="server">
  
                                <script type="text/javascript">
                                    function CodeX2IndexChanged(sender, args) {
                                        var tableView = $find("<%# ((GridItem)Container).OwnerTableView.ClientID %>");
                                        tableView.filter("CodeX2", args.get_item().get_value(), "EqualTo");
                                    }
                                </script>
  
                            </telerik:RadScriptBlock>
        </FilterTemplate>
        </telerik:GridBoundColumn>
        <telerik:GridBoundColumn DataField="CountryCode" HeaderText="CountryCode" 
            UniqueName="CountryCode">
        <FilterTemplate>
        <telerik:RadComboBox ID="RadComboBox3" DataSourceID="SqlDataSource1" DataTextField="CountryCode" AppendDataBoundItems="true" SelectedValue='<%# ((GridItem)Container).OwnerTableView.GetColumn("CountryCode").CurrentFilterValue %>' OnClientSelectedIndexChanged="CountryCodeIndexChanged" DataValueField="CountryCode" runat="server">
            </telerik:RadComboBox>
        <telerik:RadScriptBlock ID="RadScriptBlock4" runat="server">
  
                                <script type="text/javascript">
                                    function CountryCodeIndexChanged(sender, args) {
                                        var tableView = $find("<%# ((GridItem)Container).OwnerTableView.ClientID %>");
                                        tableView.filter("CountryCode", args.get_item().get_value(), "EqualTo");
                                    }
                                </script>
  
                            </telerik:RadScriptBlock>
        </FilterTemplate>
           
        </telerik:GridBoundColumn>
    </Columns>
</MasterTableView>
        </telerik:RadGrid>
     <asp:SqlDataSource ID="SqlDataSource1" runat="server" 
            ConnectionString="<%$ ConnectionStrings:sql1_DB %>" 
              
            SelectCommand="SELECT [CountryName], [MCountryID], [CodeX2], [CountryCode], [DINCode] FROM [Countries]"></asp:SqlDataSource>
    </div>
and the code behind will look like this
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Configuration;
using System.Data.SqlClient;
using Telerik.Web.UI;
  
public partial class filtertemplate : System.Web.UI.Page
{
    public static DataTable GetDataTable(string query)
    {
        string ConnString = ConfigurationManager.ConnectionStrings["sql1_DB"].ConnectionString;
        SqlConnection conn = new SqlConnection(ConnString);
        SqlDataAdapter adapter = new SqlDataAdapter();
        adapter.SelectCommand = new SqlCommand(query, conn);
  
        DataTable myDataTable = new DataTable();
  
        conn.Open();
        try
        {
            adapter.Fill(myDataTable);
        }
        finally
        {
            conn.Close();
        }
        return myDataTable;
    }
    protected void Page_Load(object sender, EventArgs e)
    {
  
    }
    protected void RadGrid1_NeedDataSource(object source, Telerik.Web.UI.GridNeedDataSourceEventArgs e)
    {
          
        RadGrid1.DataSource = GetDataTable("select  MCountryID,CountryName,CountryCode,DINCode from Countries");
    }
    protected void RadComboBox1_SelectedIndexChanged(object o, RadComboBoxSelectedIndexChangedEventArgs e)
    {
        string filterExpression;
        filterExpression = "[CountryName] = '" + e.Value + "'";
        RadGrid1.MasterTableView.FilterExpression = filterExpression;
        RadGrid1.MasterTableView.Rebind();
    }
}
Sebastian
Telerik team
 answered on 10 Mar 2011
1 answer
111 views
Hello,

I've seen in other forum posts that creating a RadComboBox dynamically in client-side JavaScript is not possible. However, these posts are a couple of years old.

Has this changed? Does the latest version of Telerik controls support dynamic creation of RadComboBoxes in client-side JavaScript?

Thanks,
Greg
Kalina
Telerik team
 answered on 10 Mar 2011
2 answers
93 views
Hello.
I need help.
I have two elements - two radcombox.
I need to do a dependency between them.
When I click or outside element, loads the second element.
I choose a value in the first list and fill the data list number two.
Description:
Two radcombobox
I need to do a cross-addiction. Lists interact with each other.

Thanks for the advice.

rAs1234
Top achievements
Rank 1
 answered on 10 Mar 2011
2 answers
136 views

Hi,

I am creating a page which is based on the example called Load on Demand RadPageView of the TabStrip in Telerik's examples app.


The code behind for the default page is:

protected void Page_Load(object sender, EventArgs e)
   {
       if (!Page.IsPostBack)
       {
           AddTab("Home");
           AddPageView(DaveRadTabStrip.FindTabByText("Home"));
           AddTab("Apps");
           AddTab("Contact");
       }
   }
  
   private void AddTab(string tabName)
   {
       RadTab tab = new RadTab();
       tab.Text = tabName;
       this.DaveRadTabStrip.Tabs.Add(tab);
   }
  
   protected void DaveRadMultiPage_PageViewCreated(object sender, RadMultiPageEventArgs e)
   {
       string userControlName = @"~/UserControls/" + e.PageView.ID + ".ascx";
  
       Control userControl = Page.LoadControl(userControlName);
       userControl.ID = e.PageView.ID + "_userControl";
       e.PageView.Controls.Add(userControl);
   }
  
   private void AddPageView(RadTab tab)
   {
       RadPageView pageView = new RadPageView();
       pageView.ID = tab.Text;
       DaveRadMultiPage.PageViews.Add(pageView);
       tab.PageViewID = pageView.ID;
   }
  
   protected void DaveRadTabStrip_TabClick(object sender, RadTabStripEventArgs e)
   {
       AddPageView(e.Tab);
       e.Tab.PageView.Selected = true;   
   }


The apps user control (for the Apps tab) has a TabStrip on it. So, I have tabs inside of a tab.

There is a javascript function which is not working. On the tabs on the Apps user control, there are some hyperlinks which load a image into a "lightbox" using a jScript plugin called FancyBox. That plugin is not working. I recognise that Telerik makes no guarantee that its controls do not work with 3rd party controls (and fair enough). But I wanted a LightBox and Telerik does not have one (RadWindow comes close, but at the end of the day, that is not its purpose - and there's no elegant animation with RadWindow either).


Here is the markup for that user control:


<%@ Control Language="C#" AutoEventWireup="true" CodeFile="Apps.ascx.cs" Inherits="UserControls_Apps" %>
 
<div id="contentOnPage">
 
        <telerik:RadCodeBlock runat="server" ID="FancyBoxCode">
            <script type="text/javascript" src='<%=Page.ResolveClientUrl("~/js/jquery.fancybox-1.3.1.js") %>'></script>
            <script type="text/javascript">
                $(document).ready(function () {
                    $("a.lib").fancybox({
                        'transitionIdn': 'fade',
                        'transitionOut': 'fade'
                    });
                });
            </script>
        </telerik:RadCodeBlock>
 
    <telerik:RadTabStrip ID="AppsRadTabStrip"
                         MultiPageID="AppsRadMultiPage"
                         SelectedIndex="0" ShowBaseLine="true"
                         runat="server">
        <Tabs>
            <telerik:RadTab Text="BookLender 2.0" PageViewID="BooklenderRadPageView2" />           
            <telerik:RadTab Text="ColorHexGrabber" PageViewID="ColorHexGrabberRadPageView" />
            <telerik:RadTab Text="BookLender 1.0" PageViewID="BooklenderRadPageView1" />
        </Tabs>
    </telerik:RadTabStrip><!--
            no spaces between the tabstrip and multipage, in order to remove unnecessary whitespace
    --><telerik:RadMultiPage ID="AppsRadMultiPage" SelectedIndex="0" runat="server" CssClass="page">
        <telerik:RadPageView ID="BooklenderRadPageView2" runat="server">
                <div>
                     
                    <img src="./images/BookLender/book.png" alt="bookLender" />
 
                    <h3>Version 2.0</h3>                               
                    <p>Have you ever lost your favourite book because you forgot who you lent it to (and they never returned it)? </p>
 
                    <p>I designed and created bookLender to help people keep a record of the books which they lend, and to whom they lend those books.</p>
                     
                    <p>There is no cost to download and use it. There is only a 64 bit version of BookLender 2.0. So if your version of Windows is only 32 bit, version 1.0 is for you.</p>
 
                    <p>I've also taken the opportunity to update it from the university-level app that it was, to a more sophisticated version. Unfortunately, there is no update path, as the underlying database design is completely different.</p>
 
                    <p>bookLender has the following functions:</p>
                        <ul class="features">
                            <li>view all books which are currently lent to your friends</li>
                            <li>manage your home library -:
                                <ul class="expanded">
                                    <li>add books </li>
                                    <li>delete books </li>
                                    <li>view a book's history</li>
                                </ul>
                            </li>
                            <li>record a book-lending </li>
                            <li>record the return of a book</li>
                        </ul>   
                                 
                    <p>
                        <a class="lib" href="./images/BookLender/library.PNG">screen shot 1</a>
                        | <a class="lib" href="./images/BookLender/lended.PNG">screen shot 2</a>
                        | <a class="lib" href="./images/BookLender/history.PNG">screen shot 3</a>
                        | <a class="lib" href="./images/BookLender/authorsOfBook.PNG">screen shot 4</a>
                        | <a class="lib" href="./images/BookLender/manageUsers.PNG">screen shot 5</a>
                    </p>
                                                                     
                    <asp:Panel ID="DownloadPanel" GroupingText="Download Area" CssClass="downloadArea"  runat="server">                           
                                <p><b>** Note ** </b> - you need to download and install the .NET Framework (v.4.0) to run bookLender 2.0.
                                Think of it as C#'s version of the java runtime environment. You can find it at <a href="http://www.microsoft.com/downloads/en/default.aspx" >
                                Microsoft's download center</a>.
                                <p>You also need to download a copy of Microsoft's SQL Server Compact Database and install it (the 64 bit version). You can get those from the download centre referenced above.</p>
                                <ul class="downloads">                                   
                                    <li><a href="./msi/BookLender2.0Setup.msi" >click here (698KB)</a> to download bookLender itself! (64 bit OS only)</li>
                                </ul>
                    </asp:Panel>
                </div>
        </telerik:RadPageView>
        <telerik:RadPageView ID="BooklenderRadPageView1" runat="server">
                <div>
 
                    <img src="images/BookLender/book.png" alt="bookLender" />
 
                    <h3>Version 1.0</h3>                               
                    <p>Have you ever lost your favourite book because you forgot who you lent it to (and they never returned it)? </p>
 
                    <p>I designed and created bookLender to help people keep a record of the books which they lend, and to whom they lend those books.</p>
                     
                    <p>There is no cost to download and use it.</p>
 
                    <p>bookLender has the following functions:</p>
                        <ul class="features">
                            <li>view all books which are currently lent to your friends</li>
                            <li>manage your home library -:
                                <ul class="expanded">
                                    <li>add books </li>
                                    <li>delete books </li>
                                    <li>view a book's history</li>
                                </ul>
                            </li>
                            <li>record a book-lending </li>
                            <li>record the return of a book</li>
                        </ul>   
                                 
                    <p>
                        <a class="lib" href="./images/BookLender/bl1.png">screen shot 1</a> |
                        <a class="lib" href="./images/BookLender/bl2.png">screen shot 2</a>
                    </p>
                                                                     
                    <asp:Panel ID="DownloadPanelBL1" GroupingText="Download Area" CssClass="downloadArea"  runat="server">                           
                                <p><b>** XP Users Note ** </b> - you need to download and install the .NET Framework (v.3.5) to run bookLender.
                                Think of it as C#'s version of the java runtime environment. You can find it at <a href="http://www.microsoft.com/downloads/en/default.aspx" >
                                Microsoft's download center</a>. (<b>Vista/Windows 7 users</b> do not need to do this.)</p>
                                <p><b>** All users **</b> - you need to download a copy of Microsoft's SQL Server Compact Database and install it. 64 bit users need the 64 bit version and 32 bit users need the 32 bit version. You can get those from the download centre referenced above.</p>
                                <ul class="downloads">                                   
                                    <li><a href="./msi/bookLender1.0Setup.msi" >click here (698KB)</a> to download bookLender itself!</li>
                                </ul>
                    </asp:Panel>
                </div>
        </telerik:RadPageView>
        <telerik:RadPageView ID="ColorHexGrabberRadPageView" runat="server">
            <div>
 
                <img src="./images/ColorHexGrabber/hexLogo.png" alt="colorHexGrabber" />
 
                <p>Being someone who uses CSS quite a bit, I wanted a quick and easy way of picking a colour and generating its respective
                hexadecimal number.</p>
                                 
                <p>Previously, I used to load up a full-scale photo editing suite (such as <a href="http://www.gimp.org/">GIMP</a>). Great as GIMP is, it was
                using a lighthouse to do the job of a single match.</p>
 
                <p>Rather than hunt around amongst the many and varied colour-choosing applications around, I decided to make my own. The
                charter which I set myself was that this application had to have absolutely bare functionality. That functionality being,
                to be able to:</p>    
                <ul class = "features">
                    <li>pick a colour from a colour palette and extract its hexadecimal value; and</li>
                    <li>pick a colour from a loaded image and extract its hexadecimal value.</li>
                </ul>   
                                 
                <p>
                    <a class="lib" href="./images/ColorHexGrabber/chg1.png">screen shot 1</a> |
                    <a class="lib" href="./images/ColorHexGrabber/chg2.jpg">screen shot 2</a>
                </p>                               
                                 
                <asp:Panel ID="DownloadPanelCHG" GroupingText="Download Area" CssClass="downloadArea"  runat="server">
                        <b>** XP Users Note **</b> - you need to download and install the .NET Framework (v.3.5) to run colorHexGrabber.
                        Think of it as C#'s version of the java runtime environment. You can find it at <a href="http://www.microsoft.com/downloads/en/default.aspx" >
                        Microsoft's download center</a>. (<b>Vista/Windows 7 users</b> do not need to do this.)
                    <ul class="downloads">
                        <li><a href="./msi/colorHexGrabberSetup.msi">click here (326KB)</a> to download colorHexGrabber itself!</li>
                    </ul>
                </asp:Panel>                               
            </div> <!--  close colorHexGrabber -->  
        </telerik:RadPageView>
    </telerik:RadMultiPage>
</div>

I really want to get to the bottom of this, to develop a better understanding of working with tabs, and AJAX and javascript and how they can all play well together. I need this skill for my job, where I develop enterprise apps using these tools. I'm happy to provide the whole VS solution if that helps (it is not that big, as I am just using it to learn concepts).

Thanks

Edit - further info. I have found that Fancybox will work without AJAX on the tabs. When I add the following AJAX, the FancyBox does not work:

<telerik:RadAjaxManagerProxy ID="DaveRadAjaxManagerProxy" runat="server">
    <AjaxSettings>
        <telerik:AjaxSetting AjaxControlID="DaveRadTabStrip">
            <UpdatedControls>
                <telerik:AjaxUpdatedControl ControlID="DaveRadTabStrip" LoadingPanelID="DarRadAjaxLoadingPanel" />
                <telerik:AjaxUpdatedControl ControlID="DaveRadMultiPage" LoadingPanelID="DarRadAjaxLoadingPanel" />                   
            </UpdatedControls>
        </telerik:AjaxSetting>
    </AjaxSettings>
</telerik:RadAjaxManagerProxy>

David
Top achievements
Rank 1
 answered on 10 Mar 2011
1 answer
120 views
I'm seeing some strangeness in e.NewPageIndex - occasionally, it is returning int.MaxValue.

The code I'm using is simplicity itself:

 

 

protected void gvApprovals_PageIndexChanged(object source, Telerik.Web.UI.GridPageChangedEventArgs e) {
  user.Options.ApprovalGrid.CurrentPage.Value = e.NewPageIndex;
}

Is there any obvious reason why it would return int.MaxValue?

Vasil
Telerik team
 answered on 10 Mar 2011
1 answer
81 views
I have a client you is wanting an internal messaging(or email like) system added to their product. The problem we are running into is sending messages to mutilble users(see screen shot). The last three messages were all sent as one message, is there any way to group these messages into one line using the radgrid without using the grouping already built into radgrid? Example: the sent to column would show a string of the the users names and the rad grid would show that message as one messge.

Marin
Telerik team
 answered on 10 Mar 2011
14 answers
171 views
Hi,

I have a Radgrid with paging and sorting enabled on page that uses url rewrite.

My page is called http://mywebsite.com/mypage.aspx but use Helicon rewrite to display the page as http://mywebsite.com/DirName/mypage/

When I click on the page numbers I get 404 can I get around this. I've tried the seo friendly paging and that doesn't work either.

Thanks
Iana Tsolova
Telerik team
 answered on 10 Mar 2011
1 answer
92 views
Hi Telerik,
I have a problem when open a modal popup in child window. There're two cases:
 - Open popup in child window: that's OK
 - Open popup on parent window: can't set height of window
Here's my code:
var oWnd = null;
var modalparent = true;
if (!modalparent) {
      // open modal popup inside
      oWnd = radopen(url);
}
else {
      // open modal popup on parent window
      oWnd = window.parent.radopen(url);
}
            
// set height, width
oWnd.SetHeight(iHeight); // it doesn't work whenopen modal popup on parent window
 oWnd.SetWidth(iWidth);
Hope you can help me, thanks.
Shinu
Top achievements
Rank 2
 answered on 10 Mar 2011
1 answer
125 views
hi,

trying to set text to radcombobox in radgrid itemtemplate and getting error "object reference not set an instance of an object"

aspx:

<

 

telerik:GridTemplateColumn HeaderText = "Print Letters/Post Cards" UniqueName = "PrintLetter" HeaderStyle-HorizontalAlign="Center" ItemStyle-HorizontalAlign

="Center">

 

 

 

<ItemTemplate

>

 

 

 

<telerik:RadComboBox ID= "Print" runat

="server">

 

 

 

<Items

>

 

 

 

<telerik:RadComboBoxItem runat="server" Text

="1 Year Postcard"/>

 

 

 

<telerik:RadComboBoxItem runat="server" Text

="1 Year Adult"/>

 

 

 

<telerik:RadComboBoxItem runat="server" Text

="2 Years Adult"/>

 

 

 

<telerik:RadComboBoxItem runat="server" Text

="3 Year"/>

 

 

 

</Items

>

 

 

 

</telerik:RadComboBox

>

 

 

 

</ItemTemplate

>

 

 

</

 

telerik:GridTemplateColumn

>

 

 


aspx.cs:

 

protected void ItemDataBound(object sender, GridItemEventArgs

e)

 

 

{

 

 

 

GridDataItem dataItem = e.Item as GridDataItem

;

 

 

 

 

RadComboBox Print = ((RadComboBox)dataItem["PrintLetter"].FindControl("Print"

));

 

 

Print.Text =

"1year"

;

 

 

}

 


Please suggest me on this.
Shinu
Top achievements
Rank 2
 answered on 10 Mar 2011
2 answers
200 views
Hello,

I am using a RadGrid which is wrapped in a RadAjaxPanel.

This RadGrid contains a user control that we are using for the editing of grid data.

On the user control, I have several textboxes, a "Save" button and a "Cancel" button.

On the Save button, I have the OnClientClick set to OnClientClick = "return CanSave();".  (I have also tried setting OnClientClick to OnClientClick="return true;" and OnClientClick = "if (CanSave()) return true;", all with the same results.)

CanSave() is a javascript procedure defined in the user control.  My Javascript is wrapped in a RadScriptBlock.

CanSave() returns a TRUE if the Save should take place.  I have verified that my "return true" line is being executed in this function.

Here is my problem:

When CanSave() returns true, no postback is happening.  If I remove the RadGrid from the RadAjax panel, it works fine when I click "Save" and CanSave() runs and returns true.  Or, if I leave the RadGrid in the RadAjax panel, and remove the OnClientClick event from the Save button and cilck the Save button, the PostBack occurs and everything works fine.

So, in short, having the RadGrid in a RadAjaxPanel and having the OnClientClick assigned to CanSave() on my user control that edits the data in the grid causes no Post Back to occur when clicking the Save button on my user control that edits the data in my RadGrid.

Any ideas as to what I might be doing wrong?  Code is below.

Here is my RadGrid:
<asp:Panel ID="pnlNewsAdmin" runat="server">
        <telerik:RadAjaxPanel ID="radAjaxPanel_MLONewsAdmin" runat="server" LoadingPanelID="radAjaxLoadingPanel_MLONewsAdmin">
            <telerik:RadAjaxLoadingPanel ID="radAjaxLoadingPanel_MLONewsAdmin" runat="server" />
            <telerik:RadGrid ID="rgNewsAdmin" runat="server" HeaderStyle-Font-Size="Smaller"
                ItemStyle-Font-Size="Smaller" AllowMultiRowSelection="false" AlternatingItemStyle-Font-Size="Smaller"
                AllowPaging="true" PageSize="10" AllowSorting="true" AllowFilteringByColumn="false"
                AutoGenerateColumns="false" GridLines="None" Skin="Default" ItemStyle-BackColor="#ddeeff"
                AlternatingItemStyle-BackColor="White" HeaderStyle-BackColor="AliceBlue" HeaderStyle-CssClass="BACGridHeader"
                OnNeedDataSource="rgNewsAdmin_OnNeedDataSource" OnInsertCommand="rgNewsAdmin_OnInsertCommand"
                OnUpdateCommand="rgNewsAdmin_OnUpdateCommand" OnDeleteCommand="rgNewsAdmin_OnDeleteCommand"
                OnItemCommand="rgNewsAdmin_OnItemCommand">
                <PagerStyle Mode="NumericPages" />
                <MasterTableView ShowHeadersWhenNoRecords="true" DataKeyNames="ManageNewsID" CommandItemDisplay="Top"
                    InsertItemPageIndexAction="ShowItemOnCurrentPage">
                    <CommandItemSettings AddNewRecordText="Add News Item..." />
                    <Columns>
                        <telerik:GridBoundColumn DataField="ManageNewsID" Visible="false" />
                        <telerik:GridBoundColumn DataField="Description" HeaderText="Description" SortExpression="Description" />
                        <telerik:GridBoundColumn DataField="URL" HeaderText="URL" SortExpression="URL" />
                        <telerik:GridTemplateColumn HeaderText="Start Date" SortExpression="StartDate">
                            <ItemTemplate>
                                <%# (DataBinder.Eval(Container,"DataItem.StartDate") != null ? DateTime.Parse(DataBinder.Eval(Container,"DataItem.StartDate").ToString()).ToShortDateString() : "") %>
                            </ItemTemplate>
                        </telerik:GridTemplateColumn>
                        <telerik:GridTemplateColumn HeaderText="Expire Date" SortExpression="ExpireDate">
                            <ItemTemplate>
                                <%# (DataBinder.Eval(Container,"DataItem.ExpireDate") != null ? DateTime.Parse(DataBinder.Eval(Container,"DataItem.ExpireDate").ToString()).ToShortDateString() : "") %>
                            </ItemTemplate>
                        </telerik:GridTemplateColumn>
                        <telerik:GridBoundColumn DataField="SelectedRoleDescriptions" HeaderText="Roles"
                            SortExpression="SelectedRoleDescriptions" ItemStyle-Width="275px" />
                        <telerik:GridEditCommandColumn ButtonType="ImageButton" EditImageUrl="edit.gif"
                            UniqueName="EditColumn" EditText="Edit News Item" />
                        <telerik:GridButtonColumn ConfirmText="Delete News Item?" UniqueName="DeleteColumn"
                            Text="Delete News Item" ConfirmTitle="Delete" ConfirmDialogType="RadWindow" CommandName="Delete"
                            ButtonType="ImageButton" ImageUrl="delete.gif" />
                    </Columns>
                    <EditFormSettings EditColumn-ButtonType="ImageButton" EditColumn-UniqueName="EditColumn"
                        UserControlName="~/EditItem.ascx" EditFormType="WebUserControl" />
                </MasterTableView>
            </telerik:RadGrid>
        </telerik:RadAjaxPanel>
    </asp:Panel>


Here is my user control:
<telerik:RadScriptBlock ID="radScriptBlock_EditMLONewsItem" runat="server">
    <script type="text/javascript">
        String.prototype.trim = function()
        {
            return this.replace(/^\s\s*/,'').replace(/\s\s*$/,'');
        }
          
        function CanSave()
        {
            var errorMsg = "";
            var txtDescription = $get("<%= txtDescription.ClientID %>");
            var txtURL = $get("<%= txtURL.ClientID %>");
            var rdpStartDate = $find("<%= rdpStartDate.ClientID %>");
            var rdpExpireDate = $find("<%= rdpExpireDate.ClientID %>");
              
            var description = txtDescription.value.trim();
            var url = txtURL.value.trim(); 
            var startDate = rdpStartDate.get_selectedDate();
            var expireDate = rdpExpireDate.get_selectedDate();
              
            if (description.length == 0)
            {
                errorMsg = "Description\n";
            }
              
            if (url.length == 0)
            {
                errorMsg = errorMsg + "URL\n";
            }
              
            if (startDate == null)
            {
                errorMsg = errorMsg + "Start Date\n";
            }
              
            if (expireDate == null)
            {
                errorMsg = errorMsg + "Expire Date\n";
            }
              
            if ((startDate != null) && (expireDate != null))
            {
                if (startDate > expireDate)
                {
                    errorMsg = errorMsg + "Start Date must occur before Expire Date.\n";
                }
            }
              
            try
            {
                if (!HasRolesSelected())
                {
                    errorMsg = errorMsg + "At least one User Role must be selected.\n";
                }
            }
            catch(e)
            {}
              
            if (errorMsg.length > 0)
            {
                alert("The following items must be completed in order to save this News Item:\n" + errorMsg);
                return false;
            }
              
            return true;
        }
    </script>
</telerik:RadScriptBlock>
  
<table>
    <tr>
        <td valign="top" width="425px">
            <table>
                <tr>
                    <td>
                        <asp:Label ID="lblDescription" runat="server" Text="Description" />
                    </td>
                    <td>
                        <asp:TextBox ID="txtDescription" runat="server" MaxLength="255" Width="300px" Text='<%# ((DataBinder.Eval(Container,"DataItem.Description").ToString() != "") ? DataBinder.Eval(Container,"DataItem.Description") : "") %>' />
                    </td>
                </tr>
                <tr>
                    <td>
                        <asp:Label ID="lblURL" runat="server" Text="URL" />
                    </td>
                    <td>
                        <asp:TextBox ID="txtURL" runat="server" MaxLength="255" Width="300px" Text='<%# ((DataBinder.Eval(Container,"DataItem.URL").ToString() != "") ? DataBinder.Eval(Container, "DataItem.URL") : "") %>' />
                          
                    </td>
                </tr>
                <tr>
                    <td>
                        <asp:Label ID="lblStartDate" runat="server" Text="Start Date" />
                    </td>
                    <td>
                        <telerik:RadDatePicker ID="rdpStartDate" runat="server" />
                    </td>
                </tr>
                <tr>
                    <td>
                        <asp:Label ID="lblExpireDate" runat="server" Text="Expire Date" />
                    </td>
                    <td>
                        <telerik:RadDatePicker ID="rdpExpireDate" runat="server" />
                    </td>
                </tr>
            </table>
        </td>
        <td>
            <table>
                <tr>
                    <td valign="top">
                        <asp:Label ID="lblRoles" runat="server" Text="Roles" />
                    </td>
                    <td>
                        <RoleSelector:roleSelector ID="roleSelector" runat="server" />
                    </td>
                </tr>
            </table>
        </td>
    </tr>
</table>
<div style="padding-top: 10px;">
    <asp:Button ID="btnInsert" runat="server" Text="Save" CommandName="PerformInsert" OnClientClick="if(CanSave())return true;"
        Visible='<%# (DataBinder.Eval(Container,"DataItem.ManageNewsID").ToString() != "" ? false : true) %>' />
    <asp:Button ID="btnUpdate" runat="server" Text="Save" CommandName="Update" OnClientClick="if (CanSave()) return true;" Visible='<%# (DataBinder.Eval(Container,"DataItem.ManageNewsID").ToString() != "" ? true : false) %>' />
    <asp:Button ID="btnCancel" runat="server" Text="Cancel" CommandName="Cancel" CausesValidation="false" />
</div>
Sébastien
Top achievements
Rank 2
 answered on 10 Mar 2011
Narrow your results
Selected tags
Tags
+? more
Top users last month
Rob
Top achievements
Rank 3
Iron
Iron
Iron
Atul
Top achievements
Rank 1
Iron
Iron
Iron
Alexander
Top achievements
Rank 1
Veteran
Iron
Serkan
Top achievements
Rank 1
Iron
Shawn
Top achievements
Rank 1
Iron
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Rob
Top achievements
Rank 3
Iron
Iron
Iron
Atul
Top achievements
Rank 1
Iron
Iron
Iron
Alexander
Top achievements
Rank 1
Veteran
Iron
Serkan
Top achievements
Rank 1
Iron
Shawn
Top achievements
Rank 1
Iron
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?