Telerik Forums
UI for ASP.NET AJAX Forum
4 answers
170 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
137 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
134 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
125 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
178 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
71 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
8 answers
246 views
This behaviour is probably by design - but I'm confused as to why I still get the child control value changed events when I hit the Cancel link - I'd have thought they would have been discarded?

So for example - I have a RadGrid with an EditCommandColumn, and a template column with a label in the ItemTemplate, and a TextBox in the EditItemTemplate.

This TextBox has a _TextChanged event which is wired up to change the column in the dataset the RadGrid is bound to.

When I hit Edit, the row goes into Edit mode, and the textbox appears. I then change the text in that textbox, but hit Cancel, rather than Update. The _TextChanged event fires first, before the RadGrid_CancelCommand - so I can't event set a bIsCancelling flag, and have an "If Not bIsCancelling" around the code in my _TextChanged event, to prevent the dataset updating code from executing.

I'm new to these controls, so I'm probably missing something obvious - I just need to know how Cancels are handled correctly with the RadGrid.

Thanks,

Andrew
Tsvetoslav
Telerik team
 answered on 08 Dec 2011
5 answers
122 views

I use 2010.1.519.40 version of Rad Controls for ASP.NET AJAX

My RadComboBox uses markfirstmatch="true and allowcustomtext="true"

Here is code snippet:

<telerik:RadComboBox ID="RadComboBox1" runat="server" AllowCustomText="True" MarkFirstMatch="True"
  DataSourceID="LinqDataSource1" DataTextField="Name" DataValueField="Id">
</telerik:RadComboBox>

It does not work in IE9.

Autocomplete does not work at all and when I type custom text into control, on postback previously selected is set and RadComboBox1.Text on server side is set to that item.

Is there any fix/workaround?

Dimitar Terziev
Telerik team
 answered on 08 Dec 2011
3 answers
392 views
Hey guys, i wonder if someone would be kind enough to help me get the <asp:ValidationSummary> inside the notification box. Specifically the validation summary when client side validation is done, like the <asp:RequiredFieldValidator> or <asp:CompareValidator>. I have already successfully accomplished this scenario on the server side with the <asp:CustomValidator>... Any help with the client side functionality of this would be great!

Thanks,

Duncan
Duncan
Top achievements
Rank 2
 answered on 08 Dec 2011
3 answers
224 views
Hello
I Followed all these steps present in this KB Link

http://www.telerik.com/support/kb/aspnet-ajax/scheduler/implement-related-radcombobox-controls-in-the-advanced-form.aspx

and in my RadComboboxes are Showing Continents and Countries (3.jpg)... and this data is coming from my Database Table.
But i am facing still problem is that.. Its all Appointments data saving in XML File... which is prestent in App_Data Folder of Zip file and i added up in Proj App_Data.

and in Default.aspx.vb this code is used for XML File...
Protected Sub Page_Init(ByVal sender As Object, ByVal e As EventArgs)
  
       Dim provider As XmlSchedulerProvider = New XmlSchedulerProvider(Server.MapPath("~/App_Data /Appointments_CustomTemplates.xml"), True)
  
       RadScheduler1.Provider = provider
   End Sub
How can I Save all this stuff into my Database SQL 2005/?
And what would I do to save all data in my SQL Database table?
Any Solution ?
Thanks
Ivana
Telerik team
 answered on 08 Dec 2011
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?