Telerik Forums
UI for ASP.NET AJAX Forum
1 answer
83 views
Hi,
I'm trying to implement the RadProgressArea with the Azure client Blob.UploadFromStream() method. I have two subs i'm using:
1) Button Click event - btnUpload_Click(sender.....), which calls the sub UploadFile(FileName, .....)
e.g.:
Protected Sub btnUpload_Click(sender As Object, e As EventArgs) Handles btnUpload.Click
Dim fileName as String = "file name"
Dim mySourceFilePath String = "file path"
............
UploadFile(mySourceFilePath, fileName)
......
End Sub

 Private Sub UploadFile(ByVal targetFolder As String, ByVal fileName As String)
' Get blob reference...
Dim myBlob As CloudBlob = GLB_blobContainer.GetBlobReference(...
' File stream...
Dim myFileStream As New FileStream(mySourceFilePath, FileMode.Open, FileAccess.Read)
Try
    blob.UploadFromStream(myFileStream)
Catch
..
End Try
End Sub
End


Can you please give me a tip on how to implement the RadProgressArea in this situation, as I am having trouble getting it to work for me?
Thank you very much!
Peter Filipov
Telerik team
 answered on 23 Jan 2012
5 answers
98 views
Hello all,

I have this page:

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="UpdateProblem.aspx.cs" Inherits="CellLab.WebForms.UpdateProblem" %>
<%@ Register TagPrefix="telerik" Namespace="Telerik.Web.UI" Assembly="Telerik.Web.UI" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="ajaxToolkit" %>
 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <telerik:RadWindowManager ID="RadWindowManagerUI" runat="server">
	</telerik:RadWindowManager>
	<asp:Button runat="server" ID="hiddenTargetControlForModalPopup" style="display:none"/>
		<telerik:RadScriptManager ID="ScriptManager1" runat="server" 
			EnableTheming="True">            
		</telerik:RadScriptManager>    
                <p>
		            <asp:Label ID="LabelMsg" runat="server" Text="Label" Visible="false"></asp:Label>
		        </p>    
            <telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" runat="server" />
            <telerik:RadAjaxPanel ID="RadAjaxPanel1" runat="server" LoadingPanelID="RadAjaxLoadingPanel1">
                <fieldset> 
			        <legend>Sample(s) information</legend> 
			        <p> 
				        <label class="demoHeaders"><b>Kit Number:</b></label>             
				        <asp:Label ID="LabelKitNumber" CssClass="demoHeaders" runat="server"></asp:Label>
			        </p>
			        <p> 
				        <label for="<%# DropDownListStudy.ClientID %>">Study: </label>             
				        <asp:DropDownList ID="DropDownListStudy" runat="server" AutoPostBack="True" onselectedindexchanged="DropDownListStudy_SelectedIndexChanged"></asp:DropDownList>  
				        <asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ErrorMessage="Study is required." Text="Study is required." ControlToValidate="DropDownListStudy" CssClass="validate_error" InitialValue="-1"></asp:RequiredFieldValidator>
			        </p>
			        <p> 
				        <label>Disease: </label>             
				        <asp:Label ID="LabelDisease" CssClass="demoHeaders" runat="server"></asp:Label>
			        </p>
			        <p> 
				        <label for="<%# TextBoxSite.ClientID %>">Site: </label>             
				        <asp:TextBox ID="TextBoxSite" CssClass="sf" runat="server"></asp:TextBox>
			        </p>
			        <p> 
				        <label for="<%# TextBoxFamNo.ClientID %>">Family number: </label>             
				        <asp:TextBox ID="TextBoxFamNo" CssClass="sf" runat="server"></asp:TextBox>
			        </p>
			        <p> 
				        <label for="<%# TextBoxIndNo.ClientID %>">Individual number: </label>             
				        <asp:TextBox ID="TextBoxIndNo" CssClass="sf" runat="server"></asp:TextBox>
			        </p>
			        <p> 
				        <label for="<%# TextBoxIndNo.ClientID %>">Notes: </label>             
				        <asp:TextBox ID="TextBoxNotes" CssClass="lf" runat="server" TextMode="MultiLine"></asp:TextBox>
			        </p>
			        <p> 
                        <label>Samples:</label><asp:LinkButton ID="LinkButtonAddEditSample" runat="server" CssClass="button" onclick="LinkButtonAddEditSample_Click" CausesValidation="false"><span class="ui-icon ui-icon-circle-plus"></span>Add Sample...</asp:LinkButton>                
			 		</p>                      
                    <telerik:RadTreeList ID="RadTreeListSamples" runat="server" AllowSorting="True" 
                        AutoGenerateColumns="False" CssClass="fullwidth" DataKeyNames="SampleNumber" 
                        EditMode="InPlace" onitemdatabound="RadTreeListSamples_ItemDataBound1" 
                        onneeddatasource="RadTreeListSamples_NeedDataSource1" 
                        onupdatecommand="RadTreeListSamples_UpdateCommand1" PageSize="15" 
                        ParentDataKeyNames="ParentSample" Skin="WebBlue" 
                        onitemcommand="RadTreeListSamples_ItemCommand">
                        <AlternatingItemStyle CssClass="odd" />
                        <Columns>
			                <telerik:TreeListBoundColumn DataField="DateReceived" UniqueName="DateReceived" HeaderText="Date Received" DataFormatString="{0:M/dd/yyyy}" HeaderStyle-Width="120"/>
			                <telerik:TreeListBoundColumn DataField="DateCollected" UniqueName="DateCollected" HeaderText="Date Collected" DataFormatString="{0:M/dd/yyyy}" HeaderStyle-Width="100"/>
			                <telerik:TreeListBoundColumn DataField="SampleNumber" UniqueName="SampleNumber" HeaderText="Sample Number" ReadOnly="true" />
			                <telerik:TreeListBoundColumn DataField="StatusId" UniqueName="StatusId" HeaderText="Status" HeaderStyle-Width="75" ReadOnly="true" />
			                <telerik:TreeListBoundColumn DataField="InitialAmount" UniqueName="InitialAmount" HeaderText="Initial Amount" HeaderStyle-Width="100"/>
			                <telerik:TreeListBoundColumn DataField="UnitId" UniqueName="UnitId" HeaderText="Units" HeaderStyle-Width="50" ReadOnly="true" />
			                <telerik:TreeListBoundColumn DataField="TubeTypeId" UniqueName="TubeTypeId" HeaderText="Tube Type" HeaderStyle-Width="100" ReadOnly="true"/>
			                <telerik:TreeListBoundColumn DataField="Notes" UniqueName="Notes" HeaderText="Notes" />
			                <telerik:TreeListBoundColumn DataField="ParentSample" UniqueName="ParentSample" HeaderText="Parent Sample" ReadOnly="true"/> 
			                <telerik:TreeListEditCommandColumn UniqueName="EditCommandColumn" ButtonType="LinkButton" ShowAddButton="false"/>                        
			                <telerik:TreeListTemplateColumn UniqueName="Deletecol" ReadOnly="true">
				                <ItemTemplate>
					                <asp:LinkButton ID="link1" Text="Delete" OnClientClick="if (!confirm('Are you sure?')) return false;"
						                CommandName="Delete" runat="server" />                        
						                <asp:HiddenField ID="ParentSample" Value='<%# Eval("ParentSample")%>' runat="server" />
				                </ItemTemplate>
			                </telerik:TreeListTemplateColumn> 
		                </Columns>
                        <NoRecordsTemplate>
                            <div class="message information">
						        <h2>No samples added yet.</h2>
						        <p>&nbsp;</p>
					        </div>
                        </NoRecordsTemplate>
                    </telerik:RadTreeList>
                </fieldset>
            </telerik:RadAjaxPanel>			   
            <ajaxToolkit:ModalPopupExtender ID="ModalPopupExtenderAddEditSample" runat="server"                
				TargetControlID="hiddenTargetControlForModalPopup"                
				PopupControlID="PanelSamples"
				BackgroundCssClass="modalBackground"                 
				DropShadow="true"                                
				>
				</ajaxToolkit:ModalPopupExtender>       
    </form>
</body>
</html>

With this Code behind:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
 
namespace CellLab.WebForms
{
    class DataTest
    {
        private DateTime dateReceived;
 
        public DateTime DateReceived
        {
            get { return dateReceived; }
            set { dateReceived = value; }
        }
        private DateTime dateCollected;
 
        public DateTime DateCollected
        {
            get { return dateCollected; }
            set { dateCollected = value; }
        }
        private string sampleNumber;
 
        public string SampleNumber
        {
            get { return sampleNumber; }
            set { sampleNumber = value; }
        }
        private string status;
 
        public string StatusId
        {
            get { return status; }
            set { status = value; }
        }
        private float initialAmount;
 
        public float InitialAmount
        {
            get { return initialAmount; }
            set { initialAmount = value; }
        }
        private string units;
 
        public string UnitId
        {
            get { return units; }
            set { units = value; }
        }
        private string tubeType;
 
        public string TubeTypeId
        {
            get { return tubeType; }
            set { tubeType = value; }
        }
        private string notes;
 
        public string Notes
        {
            get { return notes; }
            set { notes = value; }
        }
        private string parentSample;
 
        public string ParentSample
        {
            get { return parentSample; }
            set { parentSample = value; }
        }
    }
 
    public partial class UpdateProblem : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
 
        }
 
        private void BindData()
        {
            DataTest sample1 = new DataTest();
            sample1.DateReceived = DateTime.Now;
            sample1.DateCollected = DateTime.Now;
            sample1.SampleNumber = "1";
            sample1.StatusId = "NA";
            sample1.InitialAmount = 9.0f;
            sample1.UnitId = "ml";
            sample1.TubeTypeId = "ACD";
            sample1.Notes = "Notes sample 1";
            sample1.ParentSample = null;
 
            DataTest sample2 = new DataTest();
            sample2.DateReceived = DateTime.Now.AddDays(1);
            sample2.DateCollected = DateTime.Now.AddDays(1);
            sample2.SampleNumber = "2";
            sample2.StatusId = "AVAIL";
            sample2.InitialAmount = 0.0f;
            sample2.UnitId = "ml";
            sample1.TubeTypeId = "Cryovial";
            sample2.Notes = "Notes sample 2";
            sample2.ParentSample = "1";
 
            List<DataTest> rows = new List<DataTest>();
            rows.Add(sample1);
            rows.Add(sample2);
            RadTreeListSamples.DataSource = rows;
        }
 
        protected void DropDownListStudy_SelectedIndexChanged(object sender, EventArgs e)
        {
 
        }
 
        protected void LinkButtonAddEditSample_Click(object sender, EventArgs e)
        {
 
        }
 
        protected void RadTreeListSamples_ItemDataBound1(object sender, Telerik.Web.UI.TreeListItemDataBoundEventArgs e)
        {
 
        }
 
        protected void RadTreeListSamples_UpdateCommand1(object sender, Telerik.Web.UI.TreeListCommandEventArgs e)
        {
            RadWindowManagerUI.RadAlert("This is getting updated!", 330, 100, "DNA CellLab"null);
        }
 
        protected void RadTreeListSamples_NeedDataSource1(object sender, Telerik.Web.UI.TreeListNeedDataSourceEventArgs e)
        {
            BindData();
        }
 
        protected void RadTreeListSamples_ItemCommand(object sender, Telerik.Web.UI.TreeListCommandEventArgs e)
        {
 
        }
    }
}

Problem is, when I click on the edit button, and then I click on update, nothing happens. The update event is not fired at all or in other words, I don't get the RadAlert. 

Please help...

Tsvetina
Telerik team
 answered on 23 Jan 2012
1 answer
67 views
hi,

i have a requirement as follows
 in the multilevel (3 level hierarchy  ) grid i want to edit any grid row at any time but save all the changes at the final mean

if i edit row 1 , but i didn't want to update immediately to the db but i am able to see the changes in the grid itself ,next i edit 2 row and change some value but not save at that time to db at the final

i click on save changes   all the rows which are edited will be modified in the db

in the same way need the way to add new rows also .

Thanks & Regards,
M.Koteswara Rao
Jayesh Goyani
Top achievements
Rank 2
 answered on 23 Jan 2012
1 answer
124 views
hi,

i am using the telerik rad grid my code is as follows please see the code . i am using the dataset with the relations for hierarchy  that code is like this  i am using vb.net and telerik q3 version when i click on the edit the row is in edit mode but when i click on the update it did not go to ItemUpdated event why? all of your examples are based on objectect datasource or sql data data source please give at least  one example  with dataset or data table that is really good for programmers .

i wrote like this

 Protected Sub dgproduct_ItemUpdated(ByVal source As Object, ByVal e As Telerik.Web.UI.GridUpdatedEventArgs) Handles dgProduct.ItemUpdated
        Dim item As String = getItemName(e.Item.OwnerTableView.Name)
        Dim field As String = getFieldName(e.Item.OwnerTableView.Name)
        If Not e.Exception Is Nothing Then
            e.KeepInEditMode = True
            e.ExceptionHandled = True
            DisplayMessage(item + " " + e.Item(field).Text + " cannot be updated. Reason: " + e.Exception.Message)
        Else
            DisplayMessage(item + " " + e.Item(field).Text + " updated")
        End If
    End Sub

 
ds = ProductBO.GetProductChainDetailsList(ddlCategory.SelectedValue, "", txtStyle.Text, ddlStyleActive.SelectedValue, CInt(ViewState("cp").ToString), CInt(SystemSettingsBO.GetSettings("PageSize")))
           ds.Relations.Add("ProductRelation", ds.Tables(0).Columns("PKProductID"), ds.Tables(1).Columns("FKProductID"))
           If Not ds.Tables(2) Is Nothing Then
               If ds.Tables(2).Rows.Count > 0 Then
                   ds.Relations.Add("ProductRelation2", ds.Tables(1).Columns("PKProductID"), ds.Tables(2).Columns("FKProductID"))
               End If
           End If
           'dgProduct.DisplayLayout.AllowUpdateDefault = AllowUpdate.Yes
           dgProduct.DataSource = ds
           dgProduct.DataBind()

 <telerik:RadGrid ID="dgProduct" runat="server" AutoGenerateColumns="false"
                                  AutoGenerateHierarchy="true" GroupingEnabled="true" AllowMultiRowSelection="true"
                                 AllowAutomaticDeletes="True" AllowAutomaticInserts="True"  AllowAutomaticUpdates="True">
                                     <MasterTableView EditMode="InPlace" >
                                         <Columns>
                                          <telerik:GridEditCommandColumn ButtonType="ImageButton" UniqueName="EditCommandColumn1">
                                     <HeaderStyle Width="20px" />
                                     <ItemStyle CssClass="MyImageButton" />
                                 </telerik:GridEditCommandColumn>
                                             <telerik:GridBoundColumn DataField="PKProductID" HeaderText="PKProductID" Visible="false" />
                                             <telerik:GridBoundColumn DataField="SourceID" HeaderText="Style #" />
                                             <telerik:GridBoundColumn DataField="Language1Title" HeaderText="Title" />
                                             <telerik:GridBoundColumn DataField="Language1SubTitle" HeaderText="Sub Title" />
                                            
                                             <telerik:GridDropDownColumn HeaderText="Clearance" UniqueName="StyleClearance" DataSourceID="SourceCheck"
                                                 ListTextField="Text" ListValueField="Text" SortExpression="Text" DataField="ClearanceItem" />
                                             <telerik:GridDropDownColumn HeaderText="Active" UniqueName="StyleActive" DataSourceID="SourceCheck"
                                                 ListTextField="Text" ListValueField="Text" SortExpression="Text" DataField="Active" />
                                             <telerik:GridBoundColumn DataField="Price" HeaderText="Price" />
                                             <telerik:GridBoundColumn DataField="SalePrice" HeaderText="Sale Price" />
                                               <telerik:GridButtonColumn ConfirmText="Delete this product?" ButtonType="ImageButton"
                                     CommandName="Delete" Text="Delete" UniqueName="DeleteColumn1">
                                     <HeaderStyle Width="20px" />
                                     <ItemStyle HorizontalAlign="Center" CssClass="MyImageButton" />
                                 </telerik:GridButtonColumn>
                                         </Columns>
                                         <DetailTables>
                                             <telerik:GridTableView DataMember="Colors" HierarchyLoadMode="ServerOnDemand"  >
                                            
                                                 <Columns>
                                                     <telerik:GridBoundColumn DataField="FKProductid" HeaderText="FKProductid" Visible="false" />
                                                     <telerik:GridBoundColumn DataField="Language1Title" HeaderText="Title" ReadOnly="true" />
                                                      <telerik:GridBoundColumn DataField="PKGroupScaleItemID" HeaderText="Color Id" ReadOnly="true"  />
                                                     <telerik:GridTemplateColumn UniqueName="TemplateColumn">
                     <ItemTemplate>
                        sfsdadf
                     </ItemTemplate>
                     <EditItemTemplate>
                        <asp:DropDownList DataSourceID="SourceColors" DataTextField="ScaleLanguage1Name" DataValueField="ScaleType"  ID="ddlList" runat="server" AutoPostBack="true" selectedValue='<%# Eval("ScaleLanguage1Name") %>'></asp:DropDownList>
                        
                     </EditItemTemplate>
                 </telerik:GridTemplateColumn>
                                                        <telerik:GridDropDownColumn UniqueName="ColorSourceID" DataSourceID="SourceColors"
                                                         HeaderText="Colors" DataField="SourceID" SortExpression="ScaleLanguage1Name"
                                                         ListTextField="ScaleLanguage1Name" ListValueField="ScaleType" />
                                                     <telerik:GridDropDownColumn HeaderText="Active" UniqueName="ColorActive" DataSourceID="SourceCheck"
                                                         ListTextField="Text" ListValueField="Text" SortExpression="Text" DataField="Active" />
                                                 </Columns>
                                                 <DetailTables>
                                                     <telerik:GridTableView DataMember="Sizes" HierarchyLoadMode="ServerOnDemand"  Width="300px" >
                                                         <Columns>
                                                             <telerik:GridBoundColumn DataField="FKProductid" HeaderText="FKProductid" Visible="false" />
                                                             <telerik:GridBoundColumn DataField="Language1Title" HeaderText="Title" ReadOnly="true"  />
                                                             <telerik:GridBoundColumn DataField="SourceID" HeaderText="Size ID" ReadOnly="true" />
                                                             <telerik:GridDropDownColumn UniqueName="SizeSourceID" DataSourceID="SourceSizes"
                                                                 HeaderText="Sizes" DataField="SourceID" SortExpression="ScaleLanguage1Name" ListTextField="ScaleLanguage1Name"
                                                                 ListValueField="PKGroupScaleItemID" />
                                                             <telerik:GridBoundColumn DataField="BackOrderDays" HeaderText="Back Order Days" />
                                                             <telerik:GridBoundColumn DataField="SKU" HeaderText="SKU" />
                                                             <telerik:GridBoundColumn DataField="QuantityAvailable" HeaderText="Quantity" />
                                                             <telerik:GridDropDownColumn HeaderText="Active" UniqueName="SizeActive" DataSourceID="SourceCheck"
                                                                 ListTextField="Text" ListValueField="Text" SortExpression="Text" DataField="Active" />
                                                         </Columns>
                                                     </telerik:GridTableView>
                                                 </DetailTables>
                                             </telerik:GridTableView>
                                         </DetailTables>
                                         <EditFormSettings>
                                             <EditColumn Reorderable="false" Resizable="false" />
                                         </EditFormSettings>
                                     </MasterTableView>
                                     <ClientSettings>
                                         <ClientEvents OnRowClick="RowClick" OnRowDblClick="RowDblClick" />
                                         
                                     </ClientSettings>
                                 </telerik:RadGrid>


i need solution for this to update the row as early as possible

Thanks & Regards,
M.Koteswara Rao
Shinu
Top achievements
Rank 2
 answered on 23 Jan 2012
1 answer
117 views
I am using the Telerik ASP.net AJAX controls to deploy a website to a shared hosting server (Arvixe).  The site works just fine on my local server but when I FTP it to my shared hosting provider, the control (in this case grid control) does not function.  Basically I have done the following to publish my site:

1) FTP the website files to the wwwroot directory of my domain
2) FTP the Telerik .dll files to the Bin directory under the wwwroot directory of my domain

I have attempted to create the "virtual directory" as the Telerik online documentation suggests (pointing the virtual directory at the Bin directory) but this does not seem to help.  Here is the link to the documentation I attempted to follow -- http://www.telerik.com/help/aspnet-ajax/introduction-deploying-on-shared-hosting.html .  I tried calling the bin file a virtual directory but it does not seem to help. 

No errors are triggered when I resolve to the domain.  The Telerik grid control display just fine on the shared host but any of the grouping, filtering functions do not work.  When I run the website on my local server, the grouping and filtering functions operate just fine.

Has anyone had similar problem, and if so how did you resolve this issue?
Maria Ilieva
Telerik team
 answered on 23 Jan 2012
1 answer
288 views
Hi, I would like to add a rounded corner style to the Treeview nodes. I have attached a mock up of what I am looking for.

Does Telerik support the "border-radius" css property? Alternately is there another way to achieve this effect?

Any suggestions, examples, pointers or code would be very welcome.

Regards
Gary
Princy
Top achievements
Rank 2
 answered on 23 Jan 2012
1 answer
130 views
Hello,

Telerik.Web.UI Version 2010.3.1317.35

I have 2 RadListBox controls defined as follows:

 

 

<div id="dFieldSelection" style="padding:5px;" runat="server">

 

 

 

<telerik:radlistbox runat="server" DataTextField="Name" DataValueField="FieldID" ID="radListBox_1" AllowDelete="True"

 

 

 

AllowReorder="True" AllowTransfer="True" AutoPostBackOnTransfer="true" AutoPostBackOnDelete="true" TransferToID="radListBox_2">

 

 

 

</telerik:radlistbox>

 

 

 

<telerik:radlistbox runat="server" ID="radListBox_2"

 

 

 

AutoPostBackOnTransfer="true" AutoPostBackOnDelete="true"

 

 

 

ondeleting="radListBox_2_Deleting"></telerik:radlistbox>

 

 

 

</div>

I programmtically place some mandatory fields into radListBox_2...  my goal is to prevent a user from deleting these mandatory items from radListBox_2 (i.e. I have noticed that the radListBox_2_Deleting server side event get executed when the user presses the arrow button to transfer an item back to radListBox_1).

Inside of radListBox_2_Deleting server side event I simply do some code checks and if this is a mandtory item I set e.Cancel = true... hoping that that will cancel the deletion.  However, this does not appear to work as I expected.

How can I prevent a user from moving 1 RadListBoxItem from radListBox_2 back into radListBox_1?

Thx in advance!!!

 

Bozhidar
Telerik team
 answered on 23 Jan 2012
1 answer
65 views
Hello Telerik,

I have as RadScheduler that picks up my start and end dates from a datatable. There are other fields I need to put in between the time span of the start and stop dates which ispart of the same appointment. Now say I have a StartDate of 1/1/12 and an EndDate of 1/15/12. I have another field called "CutoffDate" which is 1/13/12, I need to put an image on that day INSIDE the bar for the time span of the 1/1/12 and 1/15/12 appointment on the RadScheduler.

Is this possible?

Thanks
SDI
Plamen
Telerik team
 answered on 23 Jan 2012
1 answer
81 views
We have a RadGrid with 9 columns.  We want to use a RadEdiotor for 3 of the columns and have this working except that the performance becomes terrible when there are many rows.   For example, with 200 rows in the RadGrid, with the 3 Editors per row, it takes about 30 seconds to load the page.

I realize that we could implement paging and keep it to less than 10 or 20 rows, but this experience does not work well in the situation we need to handle.

I have seen tips on improving performance for multiple RadEditors on a page, but not specifically to multiple RadEditors within a RadGrid.

Can you give us any tips on how to handle this better.

Thanks... Terry


.
Rumen
Telerik team
 answered on 23 Jan 2012
2 answers
115 views
Dear all Guru's
I have a grid as below

<telerik:RadGrid HeaderStyle-Wrap="false" ItemStyle-Wrap="true" ID="gvCustomers"
            runat="server" AutoGenerateColumns="False" GridLines="None" AllowSorting="true"
            OnNeedDataSource="gvCustomers_NeedDataSource" OnItemCommand="gvCustomers_ItemCommand">
            <MasterTableView DataKeyNames="CustomerId">
                <CommandItemSettings ExportToPdfText="Export to Pdf"></CommandItemSettings>
                <RowIndicatorColumn>
                    <HeaderStyle Width="20px"></HeaderStyle>
                </RowIndicatorColumn>
                <ExpandCollapseColumn>
                    <HeaderStyle Width="20px"></HeaderStyle>
                </ExpandCollapseColumn>
                <Columns>
                    <telerik:GridBoundColumn DataField="Title" HeaderText="Title" UniqueName="Title">
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn DataField="FName" HeaderText="First Name" UniqueName="FName">
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn DataField="LName" HeaderText="Last Name" UniqueName="LName">
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn DataField="CompanyName" HeaderText="Company" UniqueName="CompanyName">
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn DataField="Address1" HeaderText="Address 1" UniqueName="Address1">
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn DataField="Town" HeaderText="Town" UniqueName="Town">
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn DataField="Postcode" HeaderText="Postcode" UniqueName="Postcode">
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn DataField="Telephone" HeaderText="Tel" UniqueName="Telephone">
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn DataField="Mobile" HeaderText="Mobile" UniqueName="Mobile">
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn DataField="Email" HeaderText="Email" UniqueName="Email">
                    </telerik:GridBoundColumn>
                    <telerik:GridButtonColumn Text="Select" CommandName="Select" ButtonType="LinkButton"
                        UniqueName="column">
                    </telerik:GridButtonColumn>
                    <telerik:GridButtonColumn Text="Edit" CommandName="EditCustomer" ButtonType="LinkButton"
                        UniqueName="EditCustomer">
                    </telerik:GridButtonColumn>
                </Columns>
            </MasterTableView>
        </telerik:RadGrid>
And the code behind wired up as follows:
protected void gvCustomers_ItemCommand(object sender, GridCommandEventArgs e)
       {
           if (!IsPostBack)
           {
               var item = (GridDataItem) e.Item;
               string id = item.GetDataKeyValue("CustomerId").ToString();
 
               if ((e.Item is GridDataItem) && (e.CommandName == "EditCustomer"))
               {
                   var destination = string.Format("CustomerEdit.aspx?CustomerId={0}", id);
                   Response.Redirect(destination);
               }
 
               if ((e.Item is GridDataItem) && (e.CommandName == "Select"))
               {
                   var destination = string.Format("CustomerDetail.aspx?CustomerId={0}", id);
                   Response.Redirect(destination);
               }
           }
            
       }
When I sort the grid on the header I get the following error. 

 Unable to cast object of type 'Telerik.Web.UI.GridHeaderItem' to type 'Telerik.Web.UI.GridDataItem'.

Obviously if I wrap the ItemCommand in a if(!IsPostback) it doens't error but then I lose the functionality of my command buttons in the Grid.

Can someone tell what I have missed here?

Many thanks for any help
Simon
Top achievements
Rank 1
 answered on 23 Jan 2012
Narrow your results
Selected tags
Tags
+? more
Top users last month
Will
Top achievements
Rank 2
Iron
Motti
Top achievements
Rank 1
Iron
Hester
Top achievements
Rank 1
Iron
Bob
Top achievements
Rank 3
Iron
Iron
Veteran
Thomas
Top achievements
Rank 2
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Will
Top achievements
Rank 2
Iron
Motti
Top achievements
Rank 1
Iron
Hester
Top achievements
Rank 1
Iron
Bob
Top achievements
Rank 3
Iron
Iron
Veteran
Thomas
Top achievements
Rank 2
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?