Telerik Forums
UI for ASP.NET AJAX Forum
4 answers
116 views
Dear Sir,

I am using Listbox drag and drop feature for my demo application. But today I have seen a strange things happend to the drag and drop control. It lost the scollbar,Border and all arrows. Please find the attached screenshot file which has the normal and strange screens.

I am not able to re produce the error. I am using Telerik 2010 Q2 Version.

Thank you

Regards,
Muru
Murugesan Sivathanu
Top achievements
Rank 1
 answered on 09 Dec 2011
1 answer
243 views
Hello,

I'm using a RadGrid to load a very large set of records. My application pulls data from the database into a domain of business objects. On the "OnItemDataBound" event I access the bound object to configure each row. This object contains child objects that must be accessed to make determinations as well. I bind the RadGrid to a list of business objects "List<MyObject>". This is done by setting the grid datasource and then calling databind afterwards.

I have my domain setup to take in page numbers so that it only pulls back data for a specific page and loads the domain of objects for that one page. If we were to pull all data for the grid we would be loading many many business objects that would greatly decrease the performance of the grid.

My question is how can I use paging for the RadGrid and still only load up one page of data at a time? Is this even possible? Or maybe you have a better solution?

Thanks!!
Nathan
Top achievements
Rank 2
 answered on 08 Dec 2011
1 answer
69 views
I have an ajax manager in default.aspx defined as below

  <telerik:RadAjaxManager runat="server" ID="LDWorld">
              <AjaxSettings>
                 <telerik:AjaxSetting AjaxControlID="hllLove">
                    <UpdatedControls>
                       <telerik:AjaxUpdatedControl ControlID="hllLove" LoadingPanelID="pnlPeace" />
                       <telerik:AjaxUpdatedControl ControlID="radPrimaryTab" />
                       <telerik:AjaxUpdatedControl ControlID="radMultiPage" />
                    </UpdatedControls>
                 </telerik:AjaxSetting>
<telerik:AjaxSetting AjaxControlID="btnFriendship">
                    <UpdatedControls>
                       <telerik:AjaxUpdatedControl ControlID="btnFriendship" LoadingPanelID="pnlPeace" />
                       <telerik:AjaxUpdatedControl ControlID="rcbAnger" />
                       <telerik:AjaxUpdatedControl ControlID="rcbSmile" />
                    </UpdatedControls>
                 </telerik:AjaxSetting>  
              </AjaxSettings>   
</telerik:RadAjaxManager>

hllLove is in default.aspx and hence no issues. However btnFriendship, rcbAnger and rcbSmile are in 1.ascx loaded within pageview 1. 

Assuming if 2.ascx has an overlapping set of controls in this same name would it give an issue or RadAjaxManager would smartly take care of the same?

[P.S.: The names of the controls have been fictitiously provided because I can not give the exact names as in my current project]
Casey
Top achievements
Rank 1
 answered on 08 Dec 2011
2 answers
48 views
the Tabstrip click tab_click event handler does not get executed. It does only on at least after some postback in the contained page views.

I have been seeing the variants of this thread http://www.telerik.com/community/forums/aspnet-ajax/tabstrip/rad-tab-click-event-not-firing-the-first-time.aspx where there had been kind and creeds of laments to rant on this issue and a kind of callous and/or lack of response/bug fix from telerik team.

Can some one help out please?
Casey
Top achievements
Rank 1
 answered on 08 Dec 2011
4 answers
179 views
Is there a way to set the DPI settings for the chart image.  I did notice an internal property for BitmapResolution;however I did not see anyway thru the control to set that.

While I could use the code below to save a 300dpi image of the chart, isn't the source images (the generated chart) dpi set to the chart defaults? 
System.Drawing.Bitmap image = RadChart1.GetBitmap() as System.Drawing.Bitmap; 
image.SetResolution(300, 300); 
image.Save(@"C:\myimage.png");

I would not want to take at 96dpi image and convert it into a 300dpi image, where are those extra dpi's gonna come from? I think of that like taking a 200px X 200px image and resizing to 400px X 400px, which would not produce the same quality image I would get pixelation. 

I have created a Chart generator control where the user can enter data etc.. and generate the chart from the data.  Then I want to allow them to save the generated chart image at a minimum of 300dpi since this will be added to a print ready pdf.  I would want a high quality image produced since this is for printing.

I appreciate any information or advice on this matter.

Thank you!

David
Top achievements
Rank 1
 answered on 08 Dec 2011
2 answers
146 views
Afternoon everyone, I have a strange issue, when I use the jquery slidup function on a div that contains my 'search' fields and the grid in its own div, everything works fine except the loading panel. it creates its loading panel in side the grid as it should but when search fields div 'slides up' the rest of the html moves up as it should, except the loading panel... 

here is some pseudo mark up to explain what i am talking about...

<script>
  function hideSearchFields(){
       $("#searchDiv").slideUp('medium');
}
</script>
    <telerik:RadAjaxManager ID="radAjaxManager" runat="server">
        <%--<ClientEvents OnResponseEnd="RadAjaxManagerResponseEnd" />--%>
        <AjaxSettings>
            <telerik:AjaxSetting AjaxControlID="SearchLinkButton">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="ResultsRadGrid" LoadingPanelID="RadAjaxLoadingPanel1" />
                </UpdatedControls>
        </AjaxSettings>
    </telerik:RadAjaxManager>
 </telerik:AjaxSetting>
<div id="searchDiv">
      labels textboxes drop downs etc....
     <asp:linkbutton id="SearchLinkButton" runat="server" OnClientClick="hideSearchFields();" OnClick="search" />
</div>
<div>
    <telerik:radgrid id="ResultsRadGrid runat="server">
        my grid
    </telerik:radgrid>
</div>
<div>
  a bunch more html
</div>
    <telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" runat="server" Skin="Simple">
    </telerik:RadAjaxLoadingPanel>
 
Any help would be greatly appreciated! 
Josh
Top achievements
Rank 1
 answered on 08 Dec 2011
1 answer
137 views
Hi,

I have a asp .net page which has RadGrid inside the page. My objective is: on click of a button on the page, i need to get the rendered html of the radgrid so that i can do more processing (for printing/taking screenshots of the grid alone).

Grid:
<telerik:RadGrid ID="grid1" ShowFooter="true"
            OnNeedDataSource="grid1_NeedDataSource" ShowStatusBar="true" runat="server" OnItemDataBound="GridCollateralDataBound"
            AllowFilteringByColumn="false">
            <ClientSettings AllowColumnsReorder="true" ReorderColumnsOnClient="true" AllowColumnHide="true" ColumnsReorderMethod="Reorder">
                <Scrolling AllowScroll="true" SaveScrollPosition="true" UseStaticHeaders="false"  />
            </ClientSettings>
                <Columns>
                      .......

                </Columns>
        </telerik:RadGrid>

I have the button which tries to get the render html for this page but it unfortunately fails.

void ButtonClick(object sender, EventArgs e)
        {              
 
                System.IO.StringWriter stringWriter = new System.IO.StringWriter();
                HtmlTextWriter htmlWriter = new HtmlTextWriter(stringWriter);
 

 
                grid1.RenderControl(htmlWriter);
 
                if (stringWriter != null)
                    stringWriter.Dispose();
                if (htmlWriter != null)
                    htmlWriter.Dispose();

Here "grid1.RenderControl" code throws error that "Script control 'rghcMenu' is not a registered script control. Script controls must be registered using RegisterScriptControl() before calling RegisterScriptDescriptors().
Parameter name: scriptControl".

I tried setting grid1's RegisterWithScriptManager to false before calling rendercontrol and also tried adding the scriptmanager explicitly for grid1 (added a panel with scriptmanager at run-time and and then grid1 inside). All these options still were still throwing the same error.

Your help on this is appreciated.

Note: I am using the latest version of telerik radgrid: 2011.2.915.40

Regards,
Kishan G K
Kishan Gandikota
Top achievements
Rank 1
 answered on 08 Dec 2011
3 answers
135 views

This is fairly easy to accomplish using the <?hard-pagebreak?>. 

Protected Sub RadGrid1_ItemCreated(ByVal sender As Object, ByVal e As Telerik.Web.UI.GridItemEventArgs) Handles RadGrid1.ItemCreated
    If e.Item.ItemIndex Mod 7 = 0 AndAlso e.Item.ItemIndex > 1 AndAlso TypeOf e.Item Is GridDataItem Then
        e.Item.Attributes.Add("pageBreak", "pageBreak")
    End If
End Sub
This inserts a pageBreak="pageBreak" on the 8th <tr>...ie..  <tr pageBreak="pageBreak">

Then using pdfExporting you replace pagebreak="pagebreak" with closing the table, the hard pagebreak, opening the new table.  It's hard to get the tags correct because I could not find any documentation about how this xhtml is fabricated, however I was able to save the raw xhtml to file and review it to get the replace correct and fix errors. 

Protected Sub RadGrid1_PdfExporting(ByVal sender As Object, ByVal e As Telerik.Web.UI.GridPdfExportingArgs) Handles RadGrid1.PdfExporting
    Dim replacement As String = "</tbody></table><?hard-pagebreak?>" & _
                                "<table >" & _
                                    "<colgroup>" & _
                                        "<col />" & _
                                        "<col  />" & _
                                    "</colgroup>" & _
                                    "<thead>" & _
                                        "<tr>" & _
                                            "<th scope='col' > </th><th scope='col' >Print Column</th>" & _
                                        "</tr>" & _
                                    "</thead>" & _
                                    "<tbody>" & _
                                        "<tr  "
    e.RawHTML = e.RawHTML.Replace("<tr pageBreak=""pageBreak""", replacement)
    Dim FILE_NAME As String = "c:\inetpub\PDFServer\file.html"
    If System.IO.File.Exists(FILE_NAME) = True Then
        Dim objWriter As New System.IO.StreamWriter(FILE_NAME)
        objWriter.Write(e.RawHTML)
        objWriter.Close()
    End If
End Sub

This is a really great feature of radgrid as it makes fabricating these pdfs about as easy as writing html.  I just wish there was more documentation on how to do this because it took me forever to find this information.  I hope someone else can use these examples to speed up their development. 
Daniel
Telerik team
 answered on 08 Dec 2011
5 answers
187 views
Can you guys please give me a .riMulti on the root when the textbox is in multi-line mode please?  I need to style the multi differently than the normal textboxes

(in the .skin file)

So I know I can add a cssclass to the TBs in multline mode, but that means my developers will have to remember to do that, and they never will...but if I define it in the skin file, whenever they go into multiline mode it'll just be styled properly.

So my problem is the style I need to change is on the wrapper span, I know the regular is an input while multi is a textarea...
Galin
Telerik team
 answered on 08 Dec 2011
1 answer
75 views
Hi,

I have a third level hierarchical grid.I try to insert/update/delete operations in this grid.I have tried the approach given in this demo,but the problem is I can't insert or update in my second detail table.I can't add or update the data in RecipeIngredients Table.By the way,I am using Sql data source.
My question is how I can insert and update operations in my second detail table?

The database structure of hierarchy is shown below:
 
RecipeTypes(Master Table)     Recipes(Details Table)           RecipeIngredients(Details Table)        
-RecipeTypeID(PK,int)             -RecipeID(PK,int)                    -RecipeID(PK,FK,int)                          
-RecipeType(nvarchar) -RecipeTypeID(FK,int)             -IngredientID(PK,FK,int)                    
-RecipeName (nvarchar)       -IngredientName(FK,nvarchar)

 Ingredients
-IngredientID(PK,int)
 -IngredientName(PK,nvarchar)

ASPX
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="Default" %>
 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<head runat="server">
    <title></title>
    <telerik:RadStyleSheetManager ID="RadStyleSheetManager1" runat="server" />
</head>
<body>
    <form id="form1" runat="server">
    <telerik:RadScriptManager ID="RadScriptManager1" runat="server">
        <Scripts>
            <%--Needed for JavaScript IntelliSense in VS2010--%>
            <%--For VS2008 replace RadScriptManager with ScriptManager--%>
            <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.Core.js" />
            <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.jQuery.js" />
            <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.jQueryInclude.js" />
        </Scripts>
    </telerik:RadScriptManager>
    <script type="text/javascript">
        //Put your JavaScript code here.
    </script>
    <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
        <AjaxSettings>
            <telerik:AjaxSetting AjaxControlID="RadGrid1">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="RadGrid1" />
                </UpdatedControls>
            </telerik:AjaxSetting>
        </AjaxSettings>
    </telerik:RadAjaxManager>
    <div>
        <telerik:RadGrid ID="RadGrid1" runat="server" ShowStatusBar="True" AutoGenerateColumns="False"
            PageSize="3" AllowSorting="True" AllowPaging="True" GridLines="None" AllowAutomaticDeletes="True"
            AllowAutomaticInserts="True" AllowAutomaticUpdates="True" DataSourceID="SqlDataSource1"
            OnItemUpdated="RadGrid1_ItemUpdated" OnItemDeleted="RadGrid1_ItemDeleted" OnItemInserted="RadGrid1_ItemInserted"
            OnInsertCommand="RadGrid1_InsertCommand" CellSpacing="0">
            <PagerStyle Mode="NumericPages"></PagerStyle>
            <MasterTableView DataKeyNames="RecipeTypeID" AllowMultiColumnSorting="True" Width="100%"
                CommandItemDisplay="Top" Name="RecipeTypes" DataSourceID="SqlDataSource1" AllowAutomaticDeletes="true"
                AllowAutomaticInserts="true" AllowAutomaticUpdates="true">
                <DetailTables>
                    <telerik:GridTableView DataKeyNames="RecipeID" Width="100%" runat="server" CommandItemDisplay="Top"
                        Name="Recipes" DataSourceID="SqlDataSource2" AllowAutomaticDeletes="true" AllowAutomaticInserts="true"
                        AllowAutomaticUpdates="true">
                        <ParentTableRelation>
                            <telerik:GridRelationFields DetailKeyField="RecipeTypeID" MasterKeyField="RecipeTypeID" />
                        </ParentTableRelation>
                        <DetailTables>
                            <telerik:GridTableView DataKeyNames="RecipeID,IngredientID" Width="100%" runat="server"
                                CommandItemDisplay="Top" Name="RecipeIngredients" DataSourceID="SqlDataSource3"
                                AllowAutomaticDeletes="true" AllowAutomaticInserts="true" AllowAutomaticUpdates="true">
                                <ParentTableRelation>
                                    <telerik:GridRelationFields DetailKeyField="RecipeID" MasterKeyField="RecipeID" />
                                </ParentTableRelation>
                                <Columns>
                                    <telerik:GridEditCommandColumn ButtonType="ImageButton" UniqueName="EditCommandColumn1">
                                        <HeaderStyle Width="20px" />
                                        <ItemStyle CssClass="MyImageButton" />
                                    </telerik:GridEditCommandColumn>
                                    <telerik:GridBoundColumn SortExpression="RecipeID" HeaderText="RecipeID" HeaderButtonType="TextButton"
                                        DataField="RecipeID" UniqueName="RecipeID" ReadOnly="true" Visible="false">
                                    </telerik:GridBoundColumn>
                                    <telerik:GridBoundColumn SortExpression="IngredientName" HeaderText="Ingredient Name"
                                        HeaderButtonType="TextButton" DataField="IngredientName" UniqueName="IngredientName">
                                    </telerik:GridBoundColumn>
                                    <telerik:GridBoundColumn SortExpression="Quantity1" HeaderText="Quantity1" HeaderButtonType="TextButton"
                                        DataField="Quantity1" UniqueName="Quantity1">
                                    </telerik:GridBoundColumn>
                                    <telerik:GridBoundColumn SortExpression="Quantity2" HeaderText="Quantity2" HeaderButtonType="TextButton"
                                        DataField="Quantity2" UniqueName="Quantity2">
                                    </telerik:GridBoundColumn>
                                    <telerik:GridBoundColumn SortExpression="Quantity3" HeaderText="Quantity3" HeaderButtonType="TextButton"
                                        DataField="Quantity3" UniqueName="Quantity3">
                                    </telerik:GridBoundColumn>
                                    <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>
                            </telerik:GridTableView>
                        </DetailTables>
                        <Columns>
                            <telerik:GridEditCommandColumn ButtonType="ImageButton" UniqueName="EditCommandColumn2">
                                <HeaderStyle Width="20px" />
                                <ItemStyle CssClass="MyImageButton" />
                            </telerik:GridEditCommandColumn>
                            <telerik:GridBoundColumn SortExpression="RecipeID" HeaderText="RecipeID" HeaderButtonType="TextButton"
                                DataField="RecipeID" UniqueName="RecipeID" ReadOnly="true">
                            </telerik:GridBoundColumn>
                            <telerik:GridBoundColumn SortExpression="RecipeName" HeaderText="Recipe Name" HeaderButtonType="TextButton"
                                DataField="RecipeName" UniqueName="RecipeName">
                            </telerik:GridBoundColumn>
                            <telerik:GridBoundColumn SortExpression="Calories1" HeaderText="Calories 1" HeaderButtonType="TextButton"
                                DataField="Calories1" UniqueName="Calories1">
                            </telerik:GridBoundColumn>
                            <telerik:GridBoundColumn SortExpression="Calories2" HeaderText="Calories 2" HeaderButtonType="TextButton"
                                DataField="Calories2" UniqueName="Calories2">
                            </telerik:GridBoundColumn>
                            <telerik:GridBoundColumn SortExpression="Calories3" HeaderText="Calories 3" HeaderButtonType="TextButton"
                                DataField="Calories3" UniqueName="Calories3">
                            </telerik:GridBoundColumn>
                            <telerik:GridButtonColumn ConfirmText="Delete these details record?" ButtonType="ImageButton"
                                CommandName="Delete" Text="Delete" UniqueName="DeleteColumn2">
                                <HeaderStyle Width="20px" />
                                <ItemStyle HorizontalAlign="Center" CssClass="MyImageButton" />
                            </telerik:GridButtonColumn>
                        </Columns>
                    </telerik:GridTableView>
                </DetailTables>
                <Columns>
                    <telerik:GridBoundColumn SortExpression="RecipeTypeID" HeaderText="RecipeTypeID"
                        DataField="RecipeTypeID" UniqueName="RecipeTypeID" ReadOnly="true" DataType="System.Int32">
                    </telerik:GridBoundColumn>
                    <telerik:GridBoundColumn SortExpression="RecipeType" HeaderText="RecipeType" DataField="RecipeType"
                        UniqueName="RecipeType">
                    </telerik:GridBoundColumn>
                </Columns>
            </MasterTableView>
        </telerik:RadGrid>
        <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:CateringDBConnectionString %>"
            ConflictDetection="CompareAllValues" OldValuesParameterFormatString="original_{0}"
            SelectCommand="SELECT * FROM [RecipeTypes]" InsertCommand="INSERT INTO [RecipeTypes] ([RecipeType]) VALUES (@RecipeType)"
            DeleteCommand="DELETE FROM [RecipeTypes] WHERE [RecipeTypeID] = @original_RecipeTypeID"
            UpdateCommand="UPDATE [RecipeTypes] SET [RecipeType] = @RecipeType WHERE [RecipeTypeID] = @original_RecipeTypeID AND [RecipeType] = @original_RecipeType">
            <InsertParameters>
                <asp:Parameter Name="RecipeType" Type="String" />
            </InsertParameters>
            <DeleteParameters>
                <asp:Parameter Name="original_RecipeTypeID" Type="Int32" />
            </DeleteParameters>
            <UpdateParameters>
                <asp:Parameter Name="RecipeType" Type="String" />
                <asp:Parameter Name="original_RecipeTypeID" Type="Int32" />
                <asp:Parameter Name="original_RecipeType" Type="String" />
            </UpdateParameters>
        </asp:SqlDataSource>
        <asp:SqlDataSource ID="SqlDataSource2" runat="server" ConnectionString="<%$ ConnectionStrings:CateringDBConnectionString %>"
            SelectCommand="SELECT * FROM [Recipes] WHERE ([RecipeTypeID] = @RecipeTypeID)"
            InsertCommand="INSERT INTO [Recipes] ([RecipeTypeID], [RecipeName], [Calories1], [Calories2], [Calories3]) VALUES (@RecipeTypeID,@RecipeName, @Calories1, @Calories2, @Calories3)"
            DeleteCommand="DELETE FROM [Recipes] WHERE [RecipeID] = @original_RecipeID" UpdateCommand="UPDATE [Recipes] SET [RecipeName] = @RecipeName, [Calories1] = @Calories1, [Calories2] = @Calories2, [Calories3] = @Calories3 WHERE [RecipeID] = @original_RecipeID AND [RecipeName] = @original_RecipeName AND [Calories1] = @original_Calories1 AND [Calories2] = @original_Calories2 AND [Calories3] = @original_Calories3"
            ConflictDetection="CompareAllValues" OldValuesParameterFormatString="original_{0}">
            <SelectParameters>
                <asp:SessionParameter Name="RecipeTypeID" SessionField="RecipeTypeID" Type="Int32" />
            </SelectParameters>
            <InsertParameters>
                <asp:SessionParameter Name="RecipeTypeID" SessionField="RecipeTypeID" Type="Int32" />
                <asp:Parameter Name="RecipeName" Type="String" />
                <asp:Parameter Name="Calories1" Type="Int32" />
                <asp:Parameter Name="Calories2" Type="Int32" />
                <asp:Parameter Name="Calories3" Type="Int32" />
            </InsertParameters>
            <DeleteParameters>
                <asp:Parameter Name="original_RecipeID" Type="Int32" />
            </DeleteParameters>
            <UpdateParameters>
                <asp:Parameter Name="RecipeName" Type="String" />
                <asp:Parameter Name="Calories1" Type="Int32" />
                <asp:Parameter Name="Calories2" Type="Int32" />
                <asp:Parameter Name="Calories3" Type="Int32" />
                <asp:Parameter Name="original_RecipeID" Type="Int32" />
                <asp:Parameter Name="original_RecipeName" Type="String" />
                <asp:Parameter Name="original_Calories1" Type="Int32" />
                <asp:Parameter Name="original_Calories2" Type="Int32" />
                <asp:Parameter Name="original_Calories3" Type="Int32" />
            </UpdateParameters>
        </asp:SqlDataSource>
        <asp:SqlDataSource ID="SqlDataSource3" runat="server" ConnectionString="<%$ ConnectionStrings:CateringDBConnectionString %>"
            SelectCommand="SELECT * FROM [RecipeIngredients] WHERE ([RecipeID] = @RecipeID)"
            InsertCommand="INSERT INTO [RecipeIngredients] ([RecipeID], [IngredientName], [Quantity1], [Quantity2], [Quantity3]) VALUES (@RecipeID, @IngredientName, @Quantity1, @Quantity2, @Quantity3)"
            DeleteCommand="DELETE FROM [RecipeIngredients] WHERE [RecipeID] = @original_RecipeID"
            UpdateCommand="UPDATE [RecipeIngredients] SET [IngredientName] = @IngredientName, [Quantity1] = @Quantity1, [Quantity2] = @Quantity2, [Quantity3] = @Quantity3 WHERE [RecipeID] = @original_RecipeID AND [IngredientName] = @original_IngredientName AND [Quantity1] = @original_Quantity1 AND [Quantity2] = @original_Quantity2 AND [Quantity3] = @original_Quantity3"
            OldValuesParameterFormatString="original_{0}" ConflictDetection="CompareAllValues">
            <SelectParameters>
                <asp:SessionParameter Name="RecipeID" SessionField="RecipeID" Type="Int32" />
            </SelectParameters>
            <InsertParameters>
                <asp:SessionParameter Name="RecipeID" SessionField="RecipeID" Type="Int32" />
                <asp:Parameter Name="IngredientName" Type="String" />
                <asp:Parameter Name="Quantity1" Type="Int32" />
                <asp:Parameter Name="Quantity2" Type="Int32" />
                <asp:Parameter Name="Quantity3" Type="Int32" />
            </InsertParameters>
            <DeleteParameters>
                <asp:Parameter Name="original_RecipeID" Type="Int32" />
            </DeleteParameters>
            <UpdateParameters>
                <asp:Parameter Name="IngredientName" Type="String" />
                <asp:Parameter Name="Quantity1" Type="Int32" />
                <asp:Parameter Name="Quantity2" Type="Int32" />
                <asp:Parameter Name="Quantity3" Type="Int32" />
                <asp:Parameter Name="original_RecipeID" Type="Int32" />
                <asp:Parameter Name="original_IngredientName" Type="String" />
                <asp:Parameter Name="original_Quantity1" Type="Int32" />
                <asp:Parameter Name="original_Quantity2" Type="Int32" />
                <asp:Parameter Name="original_Quantity3" Type="Int32" />
            </UpdateParameters>
        </asp:SqlDataSource>
    </div>
    </form>
</body>
</html>
ASPX.CS
using System;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
 
using System.Data;
using System.Configuration;
using System.Web.Security;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using Telerik.Web.UI;
using CateringWebApp.CateringDataSetTableAdapters;
using CateringWebApp;
 
public partial class Default : System.Web.UI.Page
{
    
 
    protected void Page_Load(object sender, EventArgs e)
    {
        
    }
 
    protected void RadGrid1_ItemUpdated(object source, Telerik.Web.UI.GridUpdatedEventArgs e)
    {
        string item = getItemName(e.Item.OwnerTableView.Name);
        string field = getFieldName(e.Item.OwnerTableView.Name);
        if (e.Exception != null)
        {
            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");
        }
    }
 
    protected void RadGrid1_ItemInserted(object source, GridInsertedEventArgs e)
    {
        string item = getItemName(e.Item.OwnerTableView.Name);
        if (e.Exception != null)
        {
            e.ExceptionHandled = true;
            DisplayMessage(item + " cannot be inserted. Reason: " + e.Exception.Message);
        }
        else
        {
            DisplayMessage(item + " inserted");
        }
    }
 
    protected void RadGrid1_ItemDeleted(object source, GridDeletedEventArgs e)
    {
        string item = getItemName(e.Item.OwnerTableView.Name);
        string field = getFieldName(e.Item.OwnerTableView.Name);
        if (e.Exception != null)
        {
            e.ExceptionHandled = true;
            DisplayMessage(item + " " + e.Item[field].Text + " cannot be deleted. Reason: " + e.Exception.Message);
        }
        else
        {
            DisplayMessage(item + " " + e.Item[field].Text + " deleted");
        }
    }
 
    protected void RadGrid1_InsertCommand(object source, GridCommandEventArgs e)
    {
        if ("Recipes".Equals(e.Item.OwnerTableView.Name))
        {
            GridDataItem parentItem = (GridDataItem)e.Item.OwnerTableView.ParentItem;
            SqlDataSource2.InsertParameters["RecipeTypeID"].DefaultValue = parentItem.OwnerTableView.DataKeyValues[parentItem.ItemIndex]["RecipeTypeID"].ToString();
        }
        else if ("RecipeIngredients".Equals(e.Item.OwnerTableView.Name))
        {
            GridDataItem parentItem = (GridDataItem)e.Item.OwnerTableView.ParentItem;
            SqlDataSource3.InsertParameters["RecipeID"].DefaultValue = parentItem.OwnerTableView.DataKeyValues[parentItem.ItemIndex]["RecipeID"].ToString();
        }
    }
 
    private String getItemName(string tableName)
    {
        switch (tableName)
        {
            case ("RecipeTypes"):
                {
                    return "RecipeTypes";
                }
            case ("Recipes"):
                {
                    return "Recipes";
                }
            case ("RecipeIngredients"):
                {
                    return "RecipeIngredients";
                }
            default: return "";
        }
    }
 
    private String getFieldName(string tableName)
    {
        switch (tableName)
        {
            case ("RecipeTypes"):
                {
                    return "RecipeTypeID";
                }
            case ("Recipes"):
                {
                    return "RecipeID";
                }
            case ("RecipeIngredients"):
                {
                    return "RecipeID";
                }
            default: return "";
        }
    }
 
    private void DisplayMessage(string text)
    {
        RadGrid1.Controls.Add(new LiteralControl(string.Format("<span style='color:red'>{0}</span>", text)));
    }
 
 
 
}

Antonio Stoilkov
Telerik team
 answered on 08 Dec 2011
Narrow your results
Selected tags
Tags
+? more
Top users last month
Ambisoft
Top achievements
Rank 2
Iron
Pascal
Top achievements
Rank 2
Iron
Matthew
Top achievements
Rank 1
Sergii
Top achievements
Rank 1
Iron
Iron
Andrey
Top achievements
Rank 1
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Ambisoft
Top achievements
Rank 2
Iron
Pascal
Top achievements
Rank 2
Iron
Matthew
Top achievements
Rank 1
Sergii
Top achievements
Rank 1
Iron
Iron
Andrey
Top achievements
Rank 1
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?