Telerik Forums
UI for ASP.NET AJAX Forum
4 answers
562 views

Hi,

Does anyone have any recent examples of saving and retrieving images to/from a database? I'm using visual Studio 2008, Sql 2008 and ASP.Net AJAX Q3 2010 NET35 .

I'm using varbinary(MAX) to store the image stream and I store the contenttype and filesize in the database as well.

This is what I'm doing to save the image:

Private Sub btnSave_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnSave.Click
        If Page.IsValid Then
            Dim oProduct As New Product
            Dim iProductID As Integer = CInt(hdnProductID.Value)
            oProduct = ProductBL.GetProductByID(iProductID)
            oProduct.Name = txtName.Text.Trim
            oProduct.Description = txtDescription.Text.Trim
            Dim imgStream As Stream = fleUpload.PostedFile.InputStream
            oProduct.Filename = fleUpload.PostedFile.FileName
            oProduct.ContentType = fleUpload.PostedFile.ContentType
            oProduct.Filesize = fleUpload.PostedFile.ContentLength
            Dim imgData(oProduct.Filesize) As Byte
            oProduct.imgContent = imgData
  
            Dim oProductBL As New ProductBL
            If oProductBL.Save(oProduct) > 0 Then
                '== Show save message
            Else
                '== Show error message
            End If
        End If
  
    End Sub

Everything saves to the database without errors...but when I view the page I get an error.
This is my RadGrid:

<telerik:RadGrid ID="gridProducts" runat="server" AllowPaging="True" 
        AllowSorting="True" AutoGenerateColumns="False" GridLines="None" 
        Skin="Outlook" width="675px">
        <MasterTableView allowcustompaging="True">
        <CommandItemSettings ExportToPdfText="Export to Pdf"></CommandItemSettings>
  
        <RowIndicatorColumn>
        <HeaderStyle Width="20px"></HeaderStyle>
        </RowIndicatorColumn>
  
        <ExpandCollapseColumn>
        <HeaderStyle Width="20px"></HeaderStyle>
        </ExpandCollapseColumn>
          <Columns>
            <telerik:GridTemplateColumn HeaderText="Item" UniqueName="Item">
              <ItemTemplate>
                <telerik:RadBinaryImage ID="rbiItem" runat="server" />
              </ItemTemplate>
            </telerik:GridTemplateColumn>
            <telerik:GridTemplateColumn HeaderText="Item Description" UniqueName="ItemDescription">
              <ItemTemplate>
                <asp:Label ID="lblItem" runat="server" Text=""></asp:Label>
                <br />
                <asp:Label ID="lblDescription" runat="server" Text=""></asp:Label>
              </ItemTemplate>
            </telerik:GridTemplateColumn>
            <telerik:GridTemplateColumn HeaderText="Price" UniqueName="Price">
              <ItemTemplate>
                <asp:Label ID="lblPrice" runat="server" Text=""></asp:Label>
              </ItemTemplate>
            </telerik:GridTemplateColumn>
            <telerik:GridTemplateColumn HeaderText="Add to Cart">
              <ItemTemplate>
                <asp:ImageButton ID="imgCart" OnCommand="imgCart_Command" CommandName="Add" runat="server" />
              </ItemTemplate>
            </telerik:GridTemplateColumn>
          </Columns>
        </MasterTableView>
        <ClientSettings>
          <Selecting AllowRowSelect="True" />
        </ClientSettings>
      </telerik:RadGrid>

I'm trying to retrieve the image into the RadBinaryImage control rbiItem.
This is how I retrieve the images into a gridview:

Private Sub LoadGrid()
gridProducts.DataSource = ProductBL.GetActiveProducts
gridProducts.DataBind()
End Sub
  
Private Sub gridProducts_ItemDataBound(ByVal sender As Object, ByVal e As Telerik.Web.UI.GridItemEventArgs) Handles gridProducts.ItemDataBound
        If (TypeOf (e.Item) Is GridDataItem) Then
            Dim dr As PawnShop.Entities.Product = CType(e.Item.DataItem, PawnShop.Entities.Product)
  
            Dim lblItem As Label = CType(e.Item.FindControl("lblItem"), Label)
            lblItem.Text = dr.Name
  
            Dim lblDescription As Label = CType(e.Item.FindControl("lblDescription"), Label)
            lblDescription.Text = dr.Description
  
            Dim lblPrice As Label = CType(e.Item.FindControl("lblPrice"), Label)
            lblPrice.Text = String.Format(Constants.CURRENCY, dr.Price)
  
            Dim imgCart As ImageButton = CType(e.Item.FindControl("imgCart"), ImageButton)
            imgCart.ImageUrl = "~/images/shoping_cart_sm.png"
            imgCart.CommandArgument = dr.ProductID.ToString
            imgCart.CommandName = "Add"
                                '==Get the image from the database
            Dim rbiItem As RadBinaryImage = CType(e.Item.FindControl("rbiItem"), RadBinaryImage)  
            Response.ContentType = dr.ContentType
            rbiItem.DataValue = CType(dr.imgContent, Byte())
        End If
    End Sub
And this is the error I get:
Server Error in '/' Application.
--------------------------------------------------------------------------------
  
Parameter is not valid. 
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 
  
Exception Details: System.ArgumentException: Parameter is not valid.
  
Source Error: 
  
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.  
  
Stack Trace: 
  
  
[ArgumentException: Parameter is not valid.]
   System.Drawing.Image.FromStream(Stream stream, Boolean useEmbeddedColorManagement, Boolean validateImageData) +1062379
   System.Drawing.Image.FromStream(Stream stream) +8
   Telerik.Web.UI.ImageFilterHelper.CreateImgFromBytes(Byte[] image) +99
  
[ArgumentException: The provided binary data may not be valid image or may contains unknown header]
   Telerik.Web.UI.ImageFilterHelper.CreateImgFromBytes(Byte[] image) +173
   Telerik.Web.UI.RadBinaryImage.AutoAdjustImageElementSize(Byte[] dataValue) +51
   Telerik.Web.UI.RadBinaryImage.ProcessImageData() +188
   Telerik.Web.UI.RadBinaryImage.OnPreRender(EventArgs e) +41
   System.Web.UI.Control.PreRenderRecursiveInternal() +80
   System.Web.UI.Control.PreRenderRecursiveInternal() +171
   System.Web.UI.Control.PreRenderRecursiveInternal() +171
   System.Web.UI.Control.PreRenderRecursiveInternal() +171
   System.Web.UI.Control.PreRenderRecursiveInternal() +171
   System.Web.UI.Control.PreRenderRecursiveInternal() +171
   System.Web.UI.Control.PreRenderRecursiveInternal() +171
   System.Web.UI.Control.PreRenderRecursiveInternal() +171
   System.Web.UI.Control.PreRenderRecursiveInternal() +171
   System.Web.UI.Control.PreRenderRecursiveInternal() +171
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +842
  
   
  
  
--------------------------------------------------------------------------------
Version Information: Microsoft .NET Framework Version:2.0.50727.4952; ASP.NET Version:2.0.50727.4955

Does this mean that I'm not storing it correctly or am I not retrieving it correctly?

Can anyone help me on this?
Thanks
Rob Venable
Top achievements
Rank 1
 answered on 14 Dec 2010
4 answers
108 views

I really like the ConfirmDialogType="RadWindow" of the GridClientDeleteColumn
 and I have repurposed the Filter row as a add to grid row via other column's FilterTemplates

so instead of:

"

 

 

 

<telerik:GridTemplateColumn>

 

 

<ItemTemplate>

 

 

 

 

<asp:LinkButton ID="DeleteButton" runat="server" CommandName="Delete" OnClientClick="return Confirm('Do you really want to delete this?');"><img style="border:0px;vertical-align:middle;" alt="Delete" src="Images/Delete.png" /></asp:LinkButton>

 

 

 

 

</ItemTemplate>

 

 

 

<FilterTemplate>

 

 

 

 

<asp:LinkButton ID="AddButton" runat="server" CommandName="Add"><img style="border:0px;vertical-align:middle;" alt="Add" src="Images/Add.png" /></asp:LinkButton>

 

 

 

 

</FilterTemplate>

 

 

 

 

</telerik:GridTemplateColumn>

 

 

 

 

 

"
I want to:

"

 

<

 

telerik:GridClientDeleteColumn ConfirmDialogType="RadWindow" ButtonType="ImageButton" HeaderText="Delete" ConfirmText="Do you really want to delete this?"   ImageUrl="Images/Delete.png" UniqueName="Delete" >
<FilterTemplate>

 

 

 

 

<asp:LinkButton ID="AddButton" runat="server" CommandName="Add"><img style="border:0px;vertical-align:middle;" alt="Add" src="Images/Add.png" /></asp:LinkButton>

 

 

 

 

</FilterTemplate>

</telerik:GridClientDeleteColumn>
"

but nothing shows when its a GridClientDeleteColumn, Any ideas?

kavitha
Top achievements
Rank 1
 answered on 14 Dec 2010
2 answers
153 views
2009.3.1503.35

<meta http-equiv="x-ua-compatible" content="IE=8" />

On my page I indicated to be compatible with IE8, however if the user forces the setting to "Display all websites in Compatibility View" then the Upload's add/select button will not do anything when clicked.

Is this the expected behavior or fixed in later version of Upload?

Update:  My page has this, if this exists plus in Compatibility View is turned on, then [Select] doesn't do anything.
    <meta http-equiv="x-ua-compatible" content="IE=8" />

                    <telerik:RadUpload ID="myUpload" runat="server" InputSize="80" Width="700px" Skin="Simple"  
                        ControlObjectsVisibility="RemoveButtons"  
                        AllowedFileExtensions=".msg,.mht,.txt,.pdf,.htm,.html,.doc,.docx,.xlsx,.xls,.pptx,.ppt,.gif,.jpg,.tif" 
                        OnClientFileSelected="checkExtension"     
                        OnClientDeleting="OnClientDeletingHandler" 
                        OnClientDeletingSelected="OnClientDeletingSelectedHandler"
                    </telerik:RadUpload>  

Chris
Top achievements
Rank 1
 answered on 14 Dec 2010
4 answers
166 views
Hi,

I have a Radgrid connected to an entitydatasource with a select button, the selected row is changed and highlighted when the row is clicked. However, when the select button is clicked the selected row is changed but the highlighting does not, it only changes when the row is clicked.

I need the selected row to be highlighted when either the row is clicked or the select button is clicked.

I am new to Telerik software, can anyone point me in the right direction.

Regards

Dave 
Dave
Top achievements
Rank 1
 answered on 13 Dec 2010
10 answers
131 views
Hello,
I am receiving a strange error when a user changes their RadCombobox selection more than once.  I have a user control that contains the RadComboBox and a label that is then placed inside of RadAjax panel then depending on the user's selection I hide and show other controls.  An issue is occuring after a user does the following:
1 - They can change the drop down selection once without an issue
2 - When they change the drop down selection a second time a JavaScript error occurs


Message: Object required
Line: 292
Char: 28
Code: 0
URI: https://secure.site.com/ScriptResource.axd?d=5ut_6SXy3r9CJ2AeDds-Izp-Bg0U7_3Wu8lOt1YeQI50q7gpperlCnkV19Nk2WLlaKx9WcQKWlUj5uVQFKbhmULObFseGkumXegL3O_oU1SM3Cc7S_2xpMbRUtFsca8OdmLluHRcPbmjWamXmckZiisXYrLQhE6PANVGzpcMFMD3OhJj0&t=634078171387790179

The script resource does exist, when I copy and paste the real URL content comes back:
Type.registerNamespace("Telerik.Web.UI");
Telerik.Web.UI.RadInputComponent=function(){Telerik.Web.UI.RadInputComponent.initializeBase(this);
this._inputs=new Array();
this._radInputExtender=null;
this._emptyMessage="";
this._errorMessage="";
this._emptyMessageCss="RadInputMgr_Default RadInput_Empty_Default";
this._readOnlyCss="RadInputMgr_Default RadInput_Read_Default";
this._invalidCss="RadInputMgr_Default RadInput_Error_Default";
this._hoveredCss="RadInputMgr_Default RadInput_Hover_Default";
this._enabledCss="RadInputMgr_Default RadInput_Enabled_Default";
this._focusedCss="RadInputMgr_Default RadInput_Focused_Default";
this._disabledCss="RadInputMgr_Default RadInput_Disabled_Default";
this._selectionOnFocus=Telerik.Web.UI.SelectionOnFocus.CaretToEnd;
this._targetControlIDs=null;
this._initializeOnClient=false;
this._isRequired=false;
this._validationGroup="";
this._validateOnEvent=2;
this._location="";
this._method="";
this._onTextBoxKeyPressDelegate=null;
this._onTextBoxBlurDelegate=null;
this._onTextBoxFocusDelegate=null;
this._onTextBoxMouseOutDelegate=null;
this._onTextBoxMouseOverDelegate=null
};
Telerik.Web.UI.RadInputComponent.prototype={initialize:function(){Telerik.Web.UI.RadInputComponent.callBaseMethod(this,"initialize");
var a;
...etc.
jgill
Top achievements
Rank 1
 answered on 13 Dec 2010
4 answers
188 views
Hello,
I have a RadGrid in which I'd like to use AutoScroll. For large datasets, horizontal scrollbar extends way beyond the last column, and the result is scrolling over lot of empty space. I am NOT seeing this issue in IE or Firefox, only Chrome. Below is my client-side code:

<telerik:RadScriptManager ID="ScriptManager1" runat="server">
</telerik:RadScriptManager>
<telerik:RadFormDecorator ID="RadFormDecorator1" runat="server" />
 
<telerik:RadAjaxManager ID="RadAjaxManager2" runat="server">
    <AjaxSettings>
         <telerik:AjaxSetting AjaxControlID="datasetGrid">
            <UpdatedControls>
                <telerik:AjaxUpdatedControl ControlID="datasetGrid" LoadingPanelID="RadAjaxLoadingPanel1" />
            </UpdatedControls>
        </telerik:AjaxSetting>
    </AjaxSettings>
</telerik:RadAjaxManager>
<telerik:RadAjaxLoadingPanel
     id="RadAjaxLoadingPanel1"
     Transparency="25"
     runat="server">
     <asp:Image id="Image1" runat="server" ImageUrl="~/Content/Images/spinner.gif"></asp:Image>
</telerik:RadAjaxLoadingPanel>
    <div id="datasetGridContainer">
        <telerik:RadGrid
            ID="datasetGrid"
            OnSortCommand="datasetGrid_Sort"
            OnPageIndexChanged="datasetGrid_PageIndexChanged"  
            OnItemCommand="datasetGrid_ItemCommand"         
            AllowSorting="True"
            AllowPaging="True"
            AllowCustomPaging="true"
            OnNeedDataSource="datasetGrid_NeedDataSource"
            AllowFilteringByColumn="true"
            PageSize="100"
            runat="server"
            GridLines="None"
            Width="100%"
            OnPreRender="datasetGrid_PreRender"
            >
            <PagerStyle AlwaysVisible="true" />
            <ClientSettings>
           <Scrolling
             AllowScroll="True"
             UseStaticHeaders="True"
             ScrollHeight="480px" />
         </ClientSettings>
        </telerik:RadGrid>
    </div>

Let me know if you'd like more information.
Regards
Pete
Pete
Top achievements
Rank 1
 answered on 13 Dec 2010
6 answers
500 views
Good day.

I inherited a document lister, and I swapped the list over to be a RadListView. The  paging just worked as it was without switching to RadDataPager, and without setting AllowCustomPaging.

However, I want to be able to limit the amount of data that will be paged. The list is bound to an IQueryable of documents, and this queries in to a DB which returns dozens (or more) records. However, I only want to be able to page through X number of pages. For instance, the list I am binding to had a count of 100, but I only want to set paging to 5 per page, with a maximum of 15 (total of 3 pages).

I tried applying AllowCustomPaging=true, and using the VirtualItemCount=15, and it does cap it at a max of 15 records, but now my paging links don't work (presumably because I am not handling all of the right events and doing all I have to do to implement custom paging).

Is there something simple I can do to the following code to simply limit the total number of pages/records, or am I going to have to fully implement custom paging? Otherwise, if I switch to using RadDataPager, can this limit the total number of records? If so, how?

Thanks,

Chris

Here is the aspx code:

<asp:UpdatePanel ID="UpdatePanel1" runat="server">
    <ContentTemplate>
        <div class="WidgetDocumentBullet WidgetLink">
            <ul id="DocumentsList" runat="server">
                <telerik:RadListView ID="RadListView1" runat="server"
                    ItemPlaceholderID="LatestDocsContainer" PageSize="5"  AllowPaging="true" EnableTheming="true"  OnNeedDataSource="RadListView1_NeedDataSource" >
                    <LayoutTemplate>
                        <asp:Panel ID="PanelLatestDocs" Width="100%" runat="server">
                            <asp:PlaceHolder ID="LatestDocsContainer" runat="server"/>
                            <div style="text-align:center;padding-top:10px">
                                <asp:LinkButton  runat="server" ID="btnPrev" CommandName="Page" CommandArgument="Prev"
                                    Text="Prev" Enabled="<%#Container.CurrentPageIndex > 0 %>" />
                                <span style="vertical-aligntoppositionrelative;">
                                    <%#Container.CurrentPageIndex + 1 %>
                                    of
                                    <%#Container.PageCount %></span>
                                <asp:LinkButton runat="server" ID="btnNext" CommandName="Page" CommandArgument="Next"
                                    Text="Next" Enabled="<%#Container.CurrentPageIndex + 1 < Container.PageCount %>" />
                            </div>
                        </asp:Panel>
                    </LayoutTemplate>
                    <ItemTemplate>
                        <li>
                            <a target="_blank" runat="server" id="link" href='<%# ((Web.WidgetFramework.Utilities.DocumentDisplay) Container.DataItem).Link %>'>
                                <%# ((Web.WidgetFramework.Utilities.DocumentDisplay)Container.DataItem).Name%>
                            </a> <nobr><small style="color:Black;"><%# ((Web.WidgetFramework.Utilities.DocumentDisplay)Container.DataItem).Date.ToString("MMMM d, yyyy")%></small></nobr>
                        </li>
                        <br />
                    </ItemTemplate>
                </telerik:RadListView>
            </ul>
        </div>
    </ContentTemplate>
</asp:UpdatePanel>
Chris
Top achievements
Rank 1
 answered on 13 Dec 2010
3 answers
121 views
I run Visual Web Developer 2010 Express. I installed Web UI components and added them manually to the toolbox. But the VS extensions were not available. I tried to find the Telerik extensions for Ajax in Extension Manager->Online gallery, but nothing has appeared there in search results. I tried another search term "telerik webui vsextensions", as recommended in http://www.telerik.com/community/forums/aspnet-ajax/vs-extensions/telerik-controls-and-vs-2010.aspx , but it also returns no result. Searching for "extensions" or "telerik" also does not include the extensions.
I also ran extensions for MVC, and they also do not appear in VS, and there's no Telerik menu in VS2010.

Please advise me on that.

Erjan Gavalji
Telerik team
 answered on 13 Dec 2010
9 answers
516 views
Hi all,

I am working with Rad window control  in Rad grid.
 when i am using rad button to pop up rad window . rad window  doesn't  pop up .
but when i am using simple HTML tags like anchor tag to pop up rad window its working fine .
Please give me solution on this problem.why rad window not compatible with rad button.
Cori
Top achievements
Rank 2
 answered on 13 Dec 2010
4 answers
402 views
Hi All,

I have RadGrid with datas which works fine.

I added a new button for delete.

While deleting I get a java script error.

Microsoft JScript runtime error: Sys.WebForms.PageRequestManagerServerErrorException: Unable to cast object of type 'Telerik.Web.UI.GridCommandItem' to type 'Telerik.Web.UI.GridEditableItem'.

aspx
<%@ Page Language="C#" AutoEventWireup="True" CodeBehind="Qualification.aspx.cs" Inherits="Products.iSmart.Qualification" %>
<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 
<head runat="server">
    <title>Qualification</title>
     <style type="text/css">
        .GridPager_ImpetusBlue .radslider
        {
            float: left;
            margin: 7px 100px 0 5px;
            padding-bottom: 5px;
        }
        .sliderPagerLabel_ImpetusBlue
        {
            /*float:right;*/
            line-height: 32px;
            padding-top: 8px;
            margin-top: 8px;
        }
        tr.SelectedRow_ImpetusBlue td
        {
            background-color: #FF99FF;
        }
    </style>
    <%--<link rel="stylesheet" type="text/css" href="../Common/includes/style.css"></link>--%>
    <link href="../ImpetusBlue/Grid.ImpetusBlue.css" rel="stylesheet" type="text/css">
    </link>
    <link href="../ImpetusBlue/Menu.ImpetusBlue.css" rel="stylesheet" type="text/css">
    </link>
    <link href="../ImpetusBlue/Slider.ImpetusBlue.css" rel="stylesheet" type="text/css">
    </link>
 <telerik:RadScriptBlock runat="server" ID="RadScriptBlock1">
 
        <script type="text/javascript">
 
            function RTBQualificationclientButtonClicked(sender, args) {
 
                if (args.get_item().get_text() == "Close") {
                    GetRadWindow().Close();
                }
                if (document.getElementById("txtrgQualificationRowIndex").value != "-1") {
                    if (args.get_item().get_text() == "Delete") {
                         
                        //radalert('', null, 100, "Error");
                        radconfirm("Are You Sure, You Want To Delete this Qualification?", ConfirmReasonForDeletionFunction, 280, 100, null, 'Message');
 
                    }
                }
                else {
                    return false;
                }
            }
 
            function rgQualification_RowSelect(sender, eventArgs)
             {
                var rowindex = eventArgs.get_itemIndexHierarchical();
                document.getElementById("<%=txtrgQualificationRowIndex.ClientID%>").value = eventArgs.get_itemIndexHierarchical();
                //alert(rowindex);
 
            }
             
            function RadContextMenuQualification_ItemClientClick(sender, args) {
                document.getElementById("<%=txtMenuMode.ClientID%>").value = args.get_item().get_text();
                if (args.get_item().get_text() == "Delete") {
                    args.set_cancel(true);
                    lastClickedItem = args.get_item();
                    radconfirm("Are You Sure, You Want To Delete this Qualification?", ConfirmReasonForDeletionFunction, 280, 100, null, 'Message');
                }
                var menu = $find("<%=RadContextMenuQualification.ClientID %>");
                menu.hide();
            }
 
            function rgQualification_RowContextMenu(sender, eventArgs)
             {
                document.getElementById("rgQualificationRowIndex").value = eventArgs.get_itemIndexHierarchical();
                var menu = $find("<%=RadContextMenuQualification.ClientID %>");
                menu.show(eventArgs.get_domEvent());
 
 
            }
 
            lastClickedItem = null;
            var clickCalledAfterRadconfirm = false;
 
            function ConfirmReasonForDeletionFunction(args) {
                var Index = $get("<%=txtrgQualificationRowIndex.ClientID%>");
                if (args) {
                    radprompt('Enter Reason ', ConfirmPromptReasonForDeletionFunction, 330, 160, null, 'Reason', '');
                    return false;
                }
                else
                    clickCalledAfterRadconfirm = false;
                Index.value = -1;
                lastClickedItem = null;
            }
 
            function ConfirmPromptReasonForDeletionFunction(args) {
                if (args != null) {
                    if (args.trim()) {
                        clickCalledAfterRadconfirm = true;
                        document.getElementById("<%=txtReason.ClientID%>").value = args;
                        document.getElementById("<%=btnQualificationDelete.ClientID%>").click();
                        return true;
                    }
                    else if (args.trim() != null) {
                        clickCalledAfterRadconfirm = false;
                        radalert('Error: Enter Reason', null, 100, "Error");
                    }
                    lastClickedItem = null;
                }
            
            
        </script>
    </telerik:RadScriptBlock>
</head>
<body>
    <form id="form1" runat="server" method="post">
    <asp:ScriptManager ID="scptMgr" runat="server"></asp:ScriptManager>
   <telerik:RadAjaxLoadingPanel runat="server" ID="LoadingPanel1" IsSticky="true" Style="margin-top: 100px;
        margin-left: 400px; position: absolute; z-index: 100" Transparency="30" HorizontalAlign="Center"
        MinDisplayTime="500" BackColor="#E0E0E0">
        <asp:Image runat="server" ID="LoadingImage1" ImageUrl="~/iSmart/images/Loading.gif"
            AlternateText="Loading..." />
    </telerik:RadAjaxLoadingPanel>
    
    <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server" DefaultLoadingPanelID="LoadingPanel1">
        <AjaxSettings>
            <telerik:AjaxSetting AjaxControlID="rgQualification">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="rgQualification" />
                    <telerik:AjaxUpdatedControl ControlID="rwmMessageBox" />
                </UpdatedControls>
            </telerik:AjaxSetting>
            <telerik:AjaxSetting AjaxControlID="RadContextMenuQualification">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="rgQualification" />
                     
                </UpdatedControls>
            </telerik:AjaxSetting>
            <telerik:AjaxSetting AjaxControlID="btnQualificationDelete">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="rgQualification" />
                     
                    <telerik:AjaxUpdatedControl ControlID="txtrgQualificationRowIndex" />                   
                </UpdatedControls>
            </telerik:AjaxSetting>
            <telerik:AjaxSetting AjaxControlID="RTBQualification">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="rgQualification" />
                    <telerik:AjaxUpdatedControl ControlID="txtrgQualificationRowIndex" />
                </UpdatedControls>
            </telerik:AjaxSetting>
        </AjaxSettings>
    </telerik:RadAjaxManager>
    <table border="0" cellpadding="0" cellspacing="0" width="100%">
        <tbody>
            <tr>
                 
                <td>
                    <table width="100%" cellpadding="5px">
                        <tr>
                            <td>
                                <telerik:RadGrid ID="rgQualification" runat="server" AutoGenerateColumns="false" AllowSorting="true"
                                    AllowPaging="true" Skin="ImpetusBlue" AllowFilteringByColumn="true" Width="650px"
                                    Height="350px" PageSize="5" EnableEmbeddedSkins="false" ImagesPath="~/ImpetusBlue/Grid/"
                                    OnNeedDataSource="rgQualification_NeedDataSource" OnItemCommand="rgQualification_ItemCommand"
                                    OnUpdateCommand="rgQualification_UpdateCommand" OnInsertCommand="rgQualification_InsertCommand" OnInit="rgQualification_Init">
                                    <ClientSettings>
                                        <ClientEvents OnRowContextMenu="rgQualification_RowContextMenu" OnRowSelected="rgQualification_RowSelect" />
                                        <Scrolling AllowScroll="true" UseStaticHeaders="true" SaveScrollPosition="true" />
                                        <Selecting AllowRowSelect="true" />
                                    </ClientSettings>
                                    <PagerStyle Mode="Slider" AlwaysVisible="true" />
                                    <GroupingSettings CaseSensitive="false" />
                                    <MasterTableView AutoGenerateColumns="false" EditMode="EditForms" CommandItemDisplay="Bottom" AllowAutomaticInserts="true"
                                                     AllowAutomaticDeletes="true" DataKeyNames="QualificationID" >
                                        <CommandItemTemplate>
                                            <div>
                                                <table width="103%" border="0" cellpadding="0" cellspacing="0" style="margin-top: -2px;
                                                    margin-left: -4px; margin-bottom: -3px;">
                                                    <tr>
                                                        <telerik:RadToolBar runat="server" ID="RTBQualification" Skin="Office2007" Width="100%" OnButtonClick="RTBQualification_ButtonClick"
                                                            OnClientButtonClicked="RTBQualificationclientButtonClicked">
                                                            <%----%>
                                                            <Items>
                                                             
                                                                <telerik:RadToolBarButton Text="Add" Font-Size="9" ForeColor="#00156E" CommandName="InitInsert"
                                                                    ImagePosition="Left" ImageUrl="images/neww1.gif">
                                                                </telerik:RadToolBarButton>
                                                                <telerik:RadToolBarButton Text="Edit" Font-Size="9" ForeColor="#00156E" CommandName="Edit"
                                                                    ImagePosition="Left" ImageUrl="images/penedit.png">
                                                                </telerik:RadToolBarButton>
                                                                <telerik:RadToolBarButton Text="Delete" Font-Size="9" ForeColor="#00156E" ImagePosition="Left"
                                                                    CommandName="Delete" ImageUrl="images/delneeewww.gif">
                                                                </telerik:RadToolBarButton>
                                                                <telerik:RadToolBarButton Text="Close" Font-Size="9" ForeColor="#00156E" ImagePosition="Left"
                                                                    ImageUrl="images/closeeeeeee.gif">
                                                                </telerik:RadToolBarButton>
                                                                <telerik:RadToolBarButton Text="" Font-Size="9" Width="170px" Enabled="false" ForeColor="#00156E">
                                                                </telerik:RadToolBarButton>
                                                            </Items>
                                                        </telerik:RadToolBar>
                                                    </tr>
                                                </table>
                                            </div>
                                        </CommandItemTemplate>
                                        <Columns>
                                              <telerik:GridBoundColumn UniqueName="QualificationID" DataField="QualificationID" HeaderText="QualificationID"
                                                Visible="false" ReadOnly="true"></telerik:GridBoundColumn>
                                                <telerik:GridTemplateColumn UniqueName="Name" DataField="Name"
                                                HeaderText="QualificationName" HeaderStyle-Width="45%" ItemStyle-Width="45%"
                                                 SortExpression="Qualification Name">
                                                <ItemTemplate>
                                                    <asp:Label ID="LblName" Text='<%#Eval("QualificationName")%>' runat="server"></asp:Label>
                                                </ItemTemplate>
                                                <EditItemTemplate>
                                                    <telerik:RadTextBox ID="txtName" TextMode="SingleLine" MaxLength="5"
                                                        EnableEmbeddedSkins="false" Text='<%#Bind("QualificationName")%>' runat="server"
                                                         ToolTip="Maximum Character Allowed is 5">
                                                    </telerik:RadTextBox><asp:Label ID="Label1" runat="server" ForeColor="Red" Text="*"></asp:Label>
                                                    <asp:RequiredFieldValidator ID="RequiredFieldValidatorName" runat="server"
                                                        Display="Dynamic" ErrorMessage="Name Cannot Be Empty" ControlToValidate="txtName"></asp:RequiredFieldValidator>
                                                    <asp:Label ID="Msg" runat="server" ForeColor="Red"></asp:Label>
                                                    <asp:RegularExpressionValidator ID="RegularExpressionValidatorName"
                                                        runat="server" Display="Dynamic" ControlToValidate="txtName" ValidationExpression="^[a-zA-Z]+$"
                                                        ErrorMessage="Special Characters not Allowed"></asp:RegularExpressionValidator>
                                                    <telerik:RadTextBox runat="server" EnableEmbeddedSkins="false" ID="txtQualificationID"
                                                        Text='<%# Eval("QualificationID") %>' Style="display: none;" Visible="false">
                                                    </telerik:RadTextBox>
                                                </EditItemTemplate>
                                            </telerik:GridTemplateColumn>
                                            
                                            <telerik:GridTemplateColumn UniqueName="Category" DataField="Category"
                                                HeaderText="Category" SortExpression="QualificationCategory" HeaderStyle-Width="45%" ItemStyle-Width="45%">
                                                <ItemTemplate>
                                                    <asp:Label ID="LblCategory" Text='<%#Eval("Category")%>' runat="server"></asp:Label>
                                                </ItemTemplate>
                                                <EditItemTemplate>
                                                    <telerik:RadTextBox ID="txtCategory" TextMode="SingleLine" MaxLength="100" Text='<%#Bind("Category")%>'
                                                        runat="server" EnableEmbeddedSkins="false" ToolTip="Maximum Character Allowed is 100">
                                                    </telerik:RadTextBox><asp:Label ID="Label2" runat="server" ForeColor="Red" Text="*"></asp:Label>
                                                    <asp:RequiredFieldValidator ID="rfvCategory" runat="server"
                                                        ErrorMessage="Category Cannot Be Empty" ControlToValidate="txtCategory" Display="Dynamic"></asp:RequiredFieldValidator>
                                                </EditItemTemplate>
                                            </telerik:GridTemplateColumn>
                                        </Columns>
                                        <EditFormSettings>
                                            <EditColumn ButtonType="ImageButton">
                                            </EditColumn>
                                        </EditFormSettings>
                                        <NoRecordsTemplate>
                                            <center>
                                                No Records Found!!!</center>
                                        </NoRecordsTemplate>
                                    </MasterTableView>
                                </telerik:RadGrid>
                                <asp:Label ID="lblMsg" runat="server" ForeColor="White" Text="Impetus" Width="100%" style="text-align:right;"></asp:Label>                                                               
                            </td>
                        </tr>
                    </table>
                    
                    <telerik:RadWindowManager VisibleTitlebar="true" VisibleStatusbar="false" RestrictionZoneID="RestrictionZone"
                        Width="644px" Height="98%" Modal="true" ID="rwmMessageBox" Skin="Office2007"
                        runat="server" DestroyOnClose="true" Behaviors="Close, Move, Resize">
                    </telerik:RadWindowManager>
                    <telerik:RadContextMenu ID="RadContextMenuQualification" runat="server" Skin="Office2007" OnItemClick="RadContextMenuQualification_ItemClick"
                        OnClientItemClicking="RadContextMenuQualification_ItemClientClick">
                        <Items>
                            <telerik:RadMenuItem Text="Add" Value="Add" />
                            <telerik:RadMenuItem Text="Edit" Value="Edit" />
                            <telerik:RadMenuItem Text="Delete" Value="Delete" />
                        </Items>
                    </telerik:RadContextMenu>
                    <asp:Button ID="btnQualificationDelete" runat="server" OnClick="btnQualificationDelete_Click" Style="display: none;" />
                    <input type="hidden" id="rgQualificationRowIndex" name="rgQualificationRowIndex" />
                    <asp:TextBox ID="txtReason" runat="server" Text="0" Style="display: none;"></asp:TextBox>
                    <asp:TextBox ID="txtMenuMode" runat="server" Text="0" Style="display: none;"></asp:TextBox>
                    <asp:TextBox ID="txtrgQualificationRowIndex" runat="server" Text="-1" Style="display: none;"></asp:TextBox>
                </td>
            </tr>
        </tbody>
    </table>
    </form>
</body>
</html>


Here is the .cs page

using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using Telerik.Web.UI;
using iSmart.BLayer;
using Products.iSmart.BLayer;
 
// Created By   :Kabijoy
// Date         :05/10/2010
// Email ID     :kabijoy.e@impetusconsulting.net 
 
namespace Products.iSmart
{
    public partial class Qualification : System.Web.UI.Page
    {
        blAction objQualification = new blAction(); //Create the object, Used to call BusinessLayer Function.
        static String QualificationID, CompanyID, UserID;
 
        protected void Page_Load(object sender, EventArgs e)
        {
            
            CompanyID = "11";
            UserID = "55";
        }
 
        // To listOut the All Qualification Data Based On Company
        protected void rgQualification_NeedDataSource(object source, GridNeedDataSourceEventArgs e)
        {
 
            rgQualification.DataSource = objQualification.getQualification(CompanyID);
 
        }
 
 
        protected void rgQualification_Init(object sender, EventArgs e)
        {
            GridFilterMenu menu = rgQualification.FilterMenu;
            int i = 0;
            while (i < menu.Items.Count)
            {
                if (menu.Items[i].Text == "NoFilter" ||
                menu.Items[i].Text == "Contains" ||
                menu.Items[i].Text == "DoesNotContain" ||
                menu.Items[i].Text == "StartsWith" ||
                menu.Items[i].Text == "EndsWith")
                {
                    i++;
                }
                else
                {
                    menu.Items.RemoveAt(i);
                }
            }
        }
 
        //To delete the selected row from grid and Table
        protected void btnQualificationDelete_Click(object sender, EventArgs e)
        {
            String DeleteMessage = String.Empty;
            int rgQualificationRowIndex;
            rgQualificationRowIndex = Convert.ToInt32(txtrgQualificationRowIndex.Text);
            QualificationID = rgQualification.MasterTableView.Items[rgQualificationRowIndex]["QualificationID"].Text;
            //Name = ((Label)rgQualification.MasterTableView.Items[rgQualificationRowIndex]["Name"].FindControl("LblName")).Text;
 
            String Reason = txtReason.Text;
            try
            {
                Int32 IDD = objQualification.DeleteQualification(
                                        QualificationID,
                                        Reason,
                                        UserID,
                                        CompanyID
                    );
 
                if (IDD == -1)
                {
                    DeleteMessage = "Some Internal Problem on Deleting the Data. Try Again later";
                    UDFDisplayMessage(DeleteMessage);
 
 
                }
 
                else if(IDD==1)
                {
                    DeleteMessage = "Data Deleted Successfully";
                    rgQualification.Rebind();
                    UDFDisplayMessage(DeleteMessage);
 
                }
 
            }
            catch (Exception ex)
            {
                DeleteMessage = "Warning : " + ex.Message;
                UDFDisplayMessage(DeleteMessage);
 
            }
            Session["Message"] = DeleteMessage;
            txtrgQualificationRowIndex.Text = "-1";
        }
 
        
         
        protected void RTBQualification_ButtonClick(object sender, RadToolBarEventArgs e)
        {
            String PageClicked = e.Item.Text;
            String Message = String.Empty;
            int rgQualificationRowIndex;
 
            switch (e.Item.Text)
            {
                case "Add":
                    rgQualification.MasterTableView.IsItemInserted = true;
                    rgQualification.MasterTableView.EditFormSettings.CaptionDataField = "";
                    rgQualification.MasterTableView.EditFormSettings.CaptionFormatString = "Add New Qualification";
                    rgQualification.Rebind();
                    break;
 
                case "Edit":
 
                    if (txtrgQualificationRowIndex.Text != "-1")
                    {
                        rgQualificationRowIndex = Convert.ToInt32(txtrgQualificationRowIndex.Text);
 
                        rgQualification.MasterTableView.Items[rgQualificationRowIndex].Edit = true;
                        rgQualification.MasterTableView.EditFormSettings.CaptionDataField = "Name";
                        rgQualification.MasterTableView.EditFormSettings.CaptionFormatString = "Edit Qualification : {0}";
                        rgQualification.Rebind();
                        txtrgQualificationRowIndex.Text = "-1";
                    }
                    else
                    {
                        Message = "Select a row to Proceed";
                        UDFDisplayMessage(Message);
                    }
 
                    break;
                case "Delete":
                    //if (txtrgQualificationRowIndex.Text != "-1")
                    //{
                    //}
 
                    //else
                    //{
                    //    Message = "Select a row to Proceed";
                    //    UDFDisplayMessage(Message);
                    //}
                    break;
 
                case "Close":
                    break;
            }
        }
 
        protected void RadContextMenuQualification_ItemClick(object sender, RadMenuEventArgs e)
        {
            int rgQualificationRowIndex;
            rgQualificationRowIndex = Convert.ToInt32(txtrgQualificationRowIndex.Text);
            switch (e.Item.Value)
            {
                case "Edit":
                    rgQualification.MasterTableView.Items[rgQualificationRowIndex].Edit = true;
                    rgQualification.MasterTableView.EditFormSettings.CaptionDataField = "";
                    rgQualification.MasterTableView.EditFormSettings.CaptionFormatString = "Edit Qualification : ";
                    rgQualification.Rebind();
                    break;
                case "Add":
                    rgQualification.MasterTableView.IsItemInserted = true;
                    rgQualification.MasterTableView.EditFormSettings.CaptionDataField = "";
                    rgQualification.MasterTableView.EditFormSettings.CaptionFormatString = "Add New Qualification";
                    rgQualification.Rebind();
                    break;
                case "Delete":
                    break;
            }
        }
 
        protected void rgQualification_ItemCommand(object source, GridCommandEventArgs e)
        {
            if (e.CommandName == "Edit")
            {
                rgQualification.MasterTableView.EditFormSettings.CaptionDataField = "";
                rgQualification.MasterTableView.EditFormSettings.CaptionFormatString = "Edit Qualification : ";
            }
            else if (e.CommandName == "InitInsert")
            {
                rgQualification.MasterTableView.EditFormSettings.CaptionDataField = "";
                rgQualification.MasterTableView.EditFormSettings.CaptionFormatString = "Add New Qualification";
            }
        }
 
        //protected void rgQualification_ItemDataBound(object sender, Telerik.Web.UI.GridItemEventArgs e)
        //{
        //    if (e.Item is GridEditableItem && e.Item.IsInEditMode)
        //    {
        //        GridEditableItem item = (GridEditableItem)e.Item;
 
        //    }
 
        //}
 
        protected void saveQualification(String QualificationID, String Name, String Category,String UserId,String CompanyID, GridCommandEventArgs e)
        {
            String Message = String.Empty;
 
            try
            {
                Int32 ID = objQualification.saveQualification(
                                                        QualificationID,
                                                        Name.Trim(),
                                                        Category.Trim(),
                                                        UserId,
                                                        CompanyID
                                                     );
                if (ID == -1)
                {
                    Message = "Some Internal Problem on Saving the Data. Try Again later";
                    UDFDisplayMessage(Message);
 
                }
                else if (ID == -2)
                {
                    Message = "Error : Data Duplication. Data Already Exists";
                    UDFDisplayMessage(Message);
                }
                else if (ID == 1)
                {
                    e.Canceled = true;
                    e.Item.Edit = false;
                    Message = "Data Saved Successfully ";
                    UDFDisplayMessage(Message);
                }
                else if (ID == 2)
                {
                    e.Canceled = true;
                    e.Item.Edit = false;
                    Message = "Data Updated Successfully ";
                    rgQualification.Rebind();
                    UDFDisplayMessage(Message);
                }
 
            }
            catch (Exception ex)
            {
                Message = "Warning : " + ex.Message;
                e.Canceled = true;
                UDFDisplayMessage(Message);
            }
            txtrgQualificationRowIndex.Text = "-1";
 
        }
 
        protected void openRadWindow(RadWindowManager rwmTemp, string FileName, String Title, Int32 Width, Int32 Height)
        {
            objQualification.openRadWindow(rwmTemp, FileName, Title, Width, Height);
        }
 
        protected void rgQualification_InsertCommand(object source, GridCommandEventArgs e)
        {
 
            GridEditFormInsertItem insertedItem = (GridEditFormInsertItem)e.Item;
            Hashtable newValues = new Hashtable();
            e.Item.OwnerTableView.ExtractValuesFromItem(newValues, insertedItem);
            saveQualification(
                               "0",
                               ((RadTextBox)insertedItem.FindControl("txtName")).Text,
                               ((RadTextBox)insertedItem.FindControl("txtCategory")).Text,
                               UserID,
                               CompanyID,
                               e
                           );
 
        }
 
 
        protected void rgQualification_UpdateCommand(object source, GridCommandEventArgs e)
        {
            GridEditFormItem updatedItem = (GridEditFormItem)e.Item;
            Hashtable newValues = new Hashtable();
            e.Item.OwnerTableView.ExtractValuesFromItem(newValues, updatedItem);
            saveQualification(
                                ((RadTextBox)updatedItem.FindControl("txtQualificationID")).Text,
                                ((RadTextBox)updatedItem.FindControl("txtName")).Text,
                                ((RadTextBox)updatedItem.FindControl("txtCategory")).Text,
                                UserID,
                                CompanyID,
                                e
                            );
 
        }
 
        private void UDFDisplayMessage(string text)
        {
            rgQualification.Controls.Add(new LiteralControl(string.Format("<span style='font-weight: bold; color: red;'>{0}</span>", text)));
        }
 
        
    }
}

Is there any option to solve this.

Have even attached the screen shot.

Thanking You

-Anto
Rose
Top achievements
Rank 1
 answered on 13 Dec 2010
Narrow your results
Selected tags
Tags
+? more
Top users last month
Rob
Top achievements
Rank 3
Bronze
Bronze
Iron
Sergii
Top achievements
Rank 1
Iron
Iron
Dedalus
Top achievements
Rank 1
Iron
Iron
Lan
Top achievements
Rank 1
Iron
Doug
Top achievements
Rank 1
Want to show your ninja superpower to fellow developers?
Top users last month
Rob
Top achievements
Rank 3
Bronze
Bronze
Iron
Sergii
Top achievements
Rank 1
Iron
Iron
Dedalus
Top achievements
Rank 1
Iron
Iron
Lan
Top achievements
Rank 1
Iron
Doug
Top achievements
Rank 1
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?