Telerik Forums
UI for ASP.NET AJAX Forum
4 answers
126 views
Hello ,

I am creating a RadSplitter into my page..I have a problem..I tried to create RadPanelBar into a RadPane of the Splitter but the problem is the direction of my RadPanelBar items..I set dir="rtl" into the RadPanelBar header and to the <td> that contain it but it still display my RadPanelBar items as "ltr" direction.

I heared that RaSplitter does not support "rtl" direction .. But the question is "If I created another control inside the splitter like the RadPanelBar item , The problem will still occure"


There is no solution to create RadPanelBar as "rtl" direction of its items inside a RadPane of the Splitter ??


Hope I explanied my self well and many thanks in advance for telerik support team or any other helper
Mahmoud
Top achievements
Rank 1
 answered on 01 Nov 2010
5 answers
672 views
Hi telerik team,
I have a OA system which has many pages (use frame, not masterpage),  it allowed user to choose skin which they like, and save it to database. When he login next time, system read the setting from database and set it to all the pages.
 
Above is what I want, but I have a problem:
first , I don't want to put the RadSkinManager to each page and write code " RadSkinManager.GetCurrent(this.Page).Skin=Session["UserSkin"]; "  on Page_Load(object sender, EventArgs e){} method,  because I have too many pages.
second: I don't want to put the RadSkinManager to an usercontrol, and drag it to every page.

Is there any other ways to implement my ideal, such as new a RadSkinManager in BasePage and let other pages inherit it ? Or let every control's skin property empty and change the default skin setting which was writen in web.config before page load ? Or some other way? How should I do ?

By the way, I write some code on Page_Load Method, it doesn't work....

protected void Page_Load(object sender, EventArgs e)
{
    Telerik.Web.UI.RadSkinManager skinManager = new Telerik.Web.UI.RadSkinManager();
    skinManager.Skin = "Forest";
}


Thanks very much.
Rumen
Telerik team
 answered on 01 Nov 2010
1 answer
88 views
Hello

I am creating my own AdvancedInsertTemplate and AdvancedEditTemplate which use the RadDatePicker and RadTimePicker.

What style should I apply so that they look like the controls in the default Advanced Insert/Edit templates?

Where can I find the default CSS for the AdvancedEdit/Insert templates?

Regards,
Anthony
Veronica
Telerik team
 answered on 01 Nov 2010
1 answer
110 views
Hi,

When using LoadOnDemand, if the text I type does not exist in the datasource, i do not want the item to be selected. So when you lose focus from combobox, it the text I typed is an invalid selection, it should either be cleared or the first match should be selected. If no first match found for what is entered, it should be blank..

Basically i don't want any values/text that is not in the list.

Btw, i found that in obout suite, does telerik support this?

Thanks.

sathish
Shinu
Top achievements
Rank 2
 answered on 01 Nov 2010
2 answers
127 views
I have a RadGrid with a single row per record.  I wish to take the selected ID and populate a second grid control with extended data.  How do I access the row data that is selected from code behind?

I have an event that triggers when the person pushes select:

protected

 

 

void RadGrid1_SelectedIndexChanged(object sender, EventArgs e)

 

{
}

The problem is I don't know how to access say the column named "FirstName"?  All I want to do is Debug write the first name selected to the console but I can't seem to get access.  I've tried various GridDataItem calls and conversions from code I can find on the web but nothing I found shows a simple straightforward way to traverse the row data selected.

Any help would be appreciated. :)
Shinu
Top achievements
Rank 2
 answered on 01 Nov 2010
1 answer
111 views
Hi,

I have set a RadMaskedTextBox in one of my page with the current mask : L## ### ###. If some of the first char are missing then when i try to get the value on servervalidate of my customvalidator, the text property is always returning empty value.

Also if i set the first char correctly but add space char in middle, all the following char will not be displayed anymore after the postback.

Is there a way to keep the text the user has entered in the textbox no matter if there's a postback or not and with the space char if there's some in it?

Thx for your help,
have a nice day,
Guillaume
Veli
Telerik team
 answered on 01 Nov 2010
5 answers
489 views
Hi,

Since I upgraded my solution to ASP.NET 4 (webforms) and to Telerik RadControls 2010.1.519.40, I keep getting the following exception every time there is a new request to the server:
Exception ID:   0 
From:   System.Web 
Time of Error:  6/23/2010 6:42:06 PM 
Exception Type: System.Web.HttpException 
Exception Message:  This is an invalid webresource request. 
Exception Source:   System.Web 
Source: Path :/WebResource.axd - Raw Url :/WebResource.axd?d=ajTmsUGo059i8jVyULN6WJxyGEzDWeYyk5iXrJ-hlCbfDyKpxWCzGgr__HcHehjE45vAS9-jMMZQxEhj5WlSgsmmlvC8804M8q7f1ZWxcrM4ODuYtuHJilKNWiCjODeP0&t=634129147086009932 
Stack Trace:       at System.Web.Handlers.AssemblyResourceLoader.System.Web.IHttpHandler.ProcessRequest(HttpContext context) 
   at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() 
   at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) 

And here is how my web.config looks like just in case it can help:
<?xml version="1.0"?> 
<configuration> 
  <appSettings> 
    <add key="Telerik.ScriptManager.TelerikCdn" value="Enabled" /> 
    <add key="Telerik.StyleSheetManager.TelerikCdn" value="Enabled" /> 
  </appSettings> 
  <system.web> 
    <compilation debug="true" targetFramework="4.0" /> 
    <customErrors mode="Off" /> 
    <sessionState compressionEnabled="true"></sessionState> 
    <httpRuntime maxRequestLength="2097151" /> 
    <pages maintainScrollPositionOnPostBack="true" controlRenderingCompatibilityVersion="4.0" clientIDMode="AutoID"
    </pages> 
    <httpHandlers> 
      <add path="ChartImage.axd" type="Telerik.Web.UI.ChartHttpHandler" verb="*" validate="false" /> 
      <add path="Telerik.Web.UI.SpellCheckHandler.axd" type="Telerik.Web.UI.SpellCheckHandler" verb="*" validate="false" /> 
      <add path="Telerik.Web.UI.DialogHandler.aspx" type="Telerik.Web.UI.DialogHandler" verb="*" validate="false" /> 
      <add path="Telerik.RadUploadProgressHandler.ashx" type="Telerik.Web.UI.RadUploadProgressHandler" verb="*" validate="false" /> 
      <add path="Telerik.Web.UI.WebResource.axd" type="Telerik.Web.UI.WebResource" verb="*" validate="false" /> 
    </httpHandlers> 
    <httpModules> 
      <add name="RadUploadModule" type="Telerik.Web.UI.RadUploadHttpModule" /> 
      <add name="RadCompression" type="Telerik.Web.UI.RadCompression" /> 
    </httpModules> 
  </system.web> 
  <system.webServer> 
    <modules runAllManagedModulesForAllRequests="true"
      <remove name="RadUploadModule" /> 
      <remove name="RadCompression" /> 
      <add name="RadUploadModule" type="Telerik.Web.UI.RadUploadHttpModule" preCondition="integratedMode" /> 
      <add name="RadCompression" type="Telerik.Web.UI.RadCompression" preCondition="integratedMode" /> 
    </modules> 
    <validation validateIntegratedModeConfiguration="false" /> 
    <handlers> 
      <remove name="ChartImage_axd" /> 
      <remove name="Telerik_Web_UI_SpellCheckHandler_axd" /> 
      <remove name="Telerik_Web_UI_DialogHandler_aspx" /> 
      <remove name="Telerik_RadUploadProgressHandler_ashx" /> 
      <remove name="Telerik_Web_UI_WebResource_axd" /> 
      <add name="ChartImage_axd" path="ChartImage.axd" type="Telerik.Web.UI.ChartHttpHandler" verb="*" preCondition="integratedMode" /> 
      <add name="Telerik_Web_UI_SpellCheckHandler_axd" path="Telerik.Web.UI.SpellCheckHandler.axd" type="Telerik.Web.UI.SpellCheckHandler" verb="*" preCondition="integratedMode" /> 
      <add name="Telerik_Web_UI_DialogHandler_aspx" path="Telerik.Web.UI.DialogHandler.aspx" type="Telerik.Web.UI.DialogHandler" verb="*" preCondition="integratedMode" /> 
      <add name="Telerik_RadUploadProgressHandler_ashx" path="Telerik.RadUploadProgressHandler.ashx" type="Telerik.Web.UI.RadUploadProgressHandler" verb="*" preCondition="integratedMode" /> 
      <add name="Telerik_Web_UI_WebResource_axd" path="Telerik.Web.UI.WebResource.axd" type="Telerik.Web.UI.WebResource" verb="*" preCondition="integratedMode" /> 
    </handlers> 
    <security> 
      <requestFiltering> 
        <requestLimits maxAllowedContentLength="2147482624" /> 
      </requestFiltering> 
    </security> 
  </system.webServer> 
</configuration> 

Is anyone experiencing the same problem? Any help will be greatly appreciated!

Eric
Radoslav
Telerik team
 answered on 01 Nov 2010
3 answers
264 views
Hi,

I’m trying to bind radgrid on treeview node selected event using webservice. But it is not binding properly, it shows records without paging and also does not display checkbox and image column. Please tell me what I’m doing wrong or is that any property to set which I’m missing to add? Any advice would help. This is my code –


<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">

  <asp:ScriptManagerProxy ID="ScriptManagerProxy1" runat="server">

        <Services>

            <asp:ServiceReference Path="ProductActivateService.asmx" />

            <asp:ServiceReference Path="ProductEditService.asmx" />

        </Services>

    </asp:ScriptManagerProxy>

   

    <telerik:RadScriptBlock  ID="RadScriptBlock1" runat="server">

        <script type="text/javascript">          

           

            function ClientNodeChecked(sender, eventArgs) {

                var node = eventArgs.get_node();

                var productId = parseInt("<%= ProductId %>");

                var categoryId = parseInt(node.get_value());

                MySystem.ProductManager.ProductActivateService.AssignProductCategory(productId, categoryId, node.get_checked(), onAssignSuccess, onAssignError, node);

            }

           

            function onAssignSuccess(result, context, methodName) {

                if (!result) {

                    context.set_checked(!context.get_checked());

                }

            }

 

            function onAssignError(error, context, methodName) {

                context.set_checked(!context.get_checked());

                alert(error.get_message());

            }

           

            var commandName = "";

            var tableView = null;

            var categoryId = 62;

            var productId = parseInt("<%= ProductId %>");

 

            function pageLoad(sender, args) {

                tableView = $find("<%= RGProducts.ClientID %>").get_masterTableView();

 

                commandName = "Load"              

                MySystem.ProductManager.ProductEditService.GetProductsByCategoryId(categoryId, productId, OnClickedSuccess, OnClickedError);

            }

           

            function ClientNodeClicked(sender, eventArgs) {

                tableView = $find("<%= RGProducts.ClientID %>").get_masterTableView();

               

                var node = eventArgs.get_node();             

                categoryId = parseInt(node.get_value());

                MySystem.ProductManager.ProductEditService.GetProductsByCategoryId(categoryId, productId,OnClickedSuccess, OnClickedError);

            }

           

            function OnClickedSuccess(result) {

                if (result) {

                     tableView = $find("<%= RGProducts.ClientID %>").get_masterTableView();

                    if (tableView != null) {

                        tableView.set_dataSource(result);

                        tableView.dataBind();

                        if (commandName == "Filter" || commandName == "Load") {

                           // mySystem.ProductManager.ProductEditService.GetProductCount(updateVirtualItemCount);

                        }

                    }

                    else {

                        alert('Grid is null')

                    }                  

                }

            }

            function OnClickedError(error, context, methodName) {

                context.set_selectedd(!context.get_selected());

                alert(error.get_message());

            }

           

            function updateVirtualItemCount(result) {

                tableView.set_virtualItemCount(result);

            }

 

            function RGProducts_Command(sender, args) {

        }

 

        function RGProducts_RowDataBound(sender, args) {

            }            

          

            function checkBoxClick(sender, args) {

                //var productId = parseInt("<%= ProductId %>");

                var cProductId = args;

             

                MySystem.ProductManager.ProductActivateService.InsertRecommendedProduct(productId, cProductId);

                MySystem.ProductManager.ProductEditService.GetRecommendedProducts(productId, OnInsertSuccess, OnInsertError);               

            }

           

            function checkBoxClickMain(sender, args) {

                var checkBox = $get(sender.id);

                var cProductId =  parseInt(args);

                if (checkBox.checked == true) {

                    MySystem.ProductManager.ProductActivateService.InsertRecommendedProduct(productId, cProductId);

                }

                else {

                    MySystem.ProductManager.ProductActivateService.DeleteRecommendedProduct(productId, cProductId);

                }

                MySystem.ProductManager.ProductEditService.GetRecommendedProducts(productId, OnInsertSuccess, OnInsertError);

            }

           

            function checkBoxClickSelected(sender, args) {

                var checkBox = $get(sender.id);

                var cProductId =  parseInt(args);               

                if (checkBox.checked == true) {                  

                    MySystem.ProductManager.ProductActivateService.InsertRecommendedProduct(cProductId, productId);                   

                }

                else {                  

                    MySystem.ProductManager.ProductActivateService.DeleteRecommendedProduct(cProductId, productId);

                }

                MySystem.ProductManager.ProductEditService.GetRecommendedProducts(productId, OnInsertSuccess, OnInsertError);

            }

            function OnInsertSuccess(result) {

                if (result) {

                    var tableView = $find("<%= RGRecommendedProducts.ClientID %>").get_masterTableView();

                    if (tableView != null) {

                        tableView.set_dataSource(result);

                        tableView.dataBind();

                    }

                    else {

                        alert('Grid is null')

                    }

                }

            }

 

            function OnInsertError(error, context, methodName) {

                context.set_selectedd(!context.get_selected());

                alert(error.get_message());

            }

           

        </script>

    </telerik:RadScriptBlock >

    <style type="text/css">

        .resizebk

        {

            position: fixed;

            top: 1px;

            bottom: 0px;

        }      

        .RadPaneInner

        {

            float: left;

            width: 100%;

        }

        .RadPaneInnerText

        {

            font-weight: bold;

        }

    </style>

   

    <telerik:RadSplitter ID="RSProductCategory" runat="server" Height="99%" Width="100%"

        CssClass="resizebk" BorderSize="0">

        <telerik:RadPane ID="RPCategoryList" runat="server" Width="40%">

            <div style="margin-top: 20px 0 20px 0; vertical-align: top; width: 100%;">

                <div style="float: left;">

                    <asp:Image ID="productImage" runat="server" />

                </div>

                <div>

                    <asp:Label ID="productLabel" Font-Size="Large" runat="server" Text="Label"></asp:Label></div>

            </div>           

            <div style="float: left; width: 100%;">

                <telerik:RadTreeView runat="server" ID="rtvCategories" DataFieldID="Value" DataFieldParentID="ParentId"

                    DataTextField="Name" DataValueField="Value" PersistLoadOnDemandNodes="false" OnClientNodeClicked="ClientNodeClicked"

                    OnLoad="RadTreeView1_OnLoad" CheckBoxes="true">

                    <WebServiceSettings Path="ProductEditService.asmx" Method="GetCategoriesNodes" />

                </telerik:RadTreeView>

            </div>

        </telerik:RadPane>

        <telerik:RadSplitBar ID="RadSplitBar1" runat="server">

        </telerik:RadSplitBar>

        <telerik:RadPane ID="RPRecommendedProduct" runat="server" Width="60%">

            <telerik:RadSplitter ID="RSRecommendedProduct" Orientation="Horizontal" runat="server"

                Height="99%" CssClass="resizebk" BorderSize="0">

                <telerik:RadPane ID="RPRecommendedProTTitle" runat="server" Height="25" Width="100%">

               <div class="RadPaneInnerText">&nbsp;Recommended Product List :</div>

                </telerik:RadPane>

               

                <telerik:RadPane ID="RPRecommendedProductTop" runat="server"> 

                    <div class="RadPaneInner">

                        <telerik:RadGrid ID="RGRecommendedProducts" runat="server" GridLines="None" AllowSorting="True" Width="100%"

                            AutoGenerateColumns="False" AllowPaging="True" OnNeedDataSource="RGRecommendedProducts_NeedDataSource" >

                            <HeaderContextMenu EnableAutoScroll="True">

                            </HeaderContextMenu>

                            <MasterTableView AutoGenerateColumns="False" Width="100%" ClientDataKeyNames="ProductId,ProductSku"

                                DataKeyNames="ProductId,ProductSku" Name="Product">

                                <PagerStyle Mode="NextPrevNumericAndAdvanced" />

                                <ExpandCollapseColumn Visible="True">

                                </ExpandCollapseColumn>

                                <Columns>

                                    <telerik:GridTemplateColumn UniqueName="MasterTemplateMain" HeaderText="Sell Main Product">

                                        <ItemTemplate>

                                            <asp:CheckBox ID="cbRProductMain" runat="server" AutoPostBack="true" Checked='<%#Bind("IsMainProduct") %>' onclick='<%# "return checkBoxClickMain(this," + Eval("ProductId")+ ");" %>'></asp:CheckBox>

                                        </ItemTemplate>

                                    </telerik:GridTemplateColumn>

                                    <telerik:GridTemplateColumn UniqueName="MasterTemplateSelected" HeaderText="Sell Selected Product">

                                        <ItemTemplate>

                                            <asp:CheckBox ID="cbRProductSelected" runat="server" AutoPostBack="true" Checked='<%#Bind("IsSubProduct") %>' onclick='<%# "return checkBoxClickSelected(this," + Eval("ProductId")+ ");" %>'></asp:CheckBox>

                                        </ItemTemplate>

                                    </telerik:GridTemplateColumn>

                                    <telerik:GridImageColumn HeaderText="Picture" ImageHeight="44" ImageWidth="44" DataImageUrlFields="ProductImageUrl"

                                        UniqueName="ProductImageUrl">

                                    </telerik:GridImageColumn>

                                    <telerik:GridBoundColumn DataField="ProductSku" HeaderText="SKU" UniqueName="ProductSkuColumn">

                                        <ItemStyle HorizontalAlign="Left" />

                                    </telerik:GridBoundColumn>

                                    <telerik:GridBoundColumn DataField="ProductName" HeaderText="Product Name" UniqueName="ProductNameColumn">

                                        <ItemStyle HorizontalAlign="Left" />

                                    </telerik:GridBoundColumn>

                                    <telerik:GridBoundColumn DataField="ProductId" HeaderText="ProductId" UniqueName="ProductIdcolumn"

                                        Visible="False">

                                    </telerik:GridBoundColumn>

                                </Columns>

                            </MasterTableView>

                            <PagerStyle AlwaysVisible="true" Mode="NextPrevAndNumeric"/>

                           <ClientSettings>                               

                                <ClientEvents OnCommand="function(){}" />

                            </ClientSettings>

                        </telerik:RadGrid>

                    </div>            

                </telerik:RadPane>

               

                <telerik:RadPane ID="RPRecommendedProBTitle" runat="server" Height="25" Width="100%">

                <div class="RadPaneInnerText">&nbsp;Filtered Product List :</div>

                </telerik:RadPane>

               

                <telerik:RadPane ID="RPRecommendedProductBottom" runat="server">                  

                    <div class="RadPaneInner">

                        <telerik:RadGrid ID="RGProducts" runat="server" GridLines="None" AllowSorting="True"

                             OnNeedDataSource="RGProducts_NeedDataSource" ShowHeader="true"

                            AutoGenerateColumns="False" AllowPaging="True" PageSize="10" Width="100%">

                            <HeaderContextMenu EnableAutoScroll="True">

                            </HeaderContextMenu>                           

                            <MasterTableView AutoGenerateColumns="False" Width="100%" ClientDataKeyNames="ProductId,ProductSku" AllowPaging="true"

                                DataKeyNames="ProductId,ProductSku" Name="Product" AllowFilteringByColumn="true" CommandItemDisplay="Top">

                                <PagerStyle Mode="NextPrevAndNumeric" />

                                <ExpandCollapseColumn Visible="True">

                                </ExpandCollapseColumn>

                                <Columns>                              

                                    <telerik:GridTemplateColumn UniqueName="MasterTemplateRecommend" HeaderText="Recommend" AllowFiltering="false">

                                        <ItemTemplate>

                                            <asp:CheckBox ID="cbRProduct" runat="server" AutoPostBack="false" onclick='<%# "return checkBoxClick(this," + Eval("ProductId")+ ");" %>'>

                                            </asp:CheckBox>                                                                                

                                        </ItemTemplate>

                                    </telerik:GridTemplateColumn>                                   

                                    <telerik:GridImageColumn HeaderText="Picture" ImageHeight="44" ImageWidth="44" DataImageUrlFields="ProductImageUrl"

                                        UniqueName="ProductImages" AllowFiltering="false" AlternateText="test">

                                    </telerik:GridImageColumn>

                                    <telerik:GridBoundColumn DataField="ProductSku" HeaderText="SKU" UniqueName="ProductSkuColumn">

                                        <ItemStyle HorizontalAlign="Left" />

                                    </telerik:GridBoundColumn>

                                    <telerik:GridBoundColumn DataField="ProductName" HeaderText="Product Name" UniqueName="ProductNameColumn">

                                        <ItemStyle HorizontalAlign="Left" />

                                    </telerik:GridBoundColumn>

                                    <telerik:GridBoundColumn DataField="ProductId" HeaderText="ProductId" UniqueName="ProductIdcolumn"

                                        Visible="False">

                                    </telerik:GridBoundColumn>

                                    <telerik:GridTemplateColumn UniqueName="ProductImageUrl" HeaderText="Image" DataField="ProductImageUrl" AllowFiltering="false">

                                        <ItemTemplate>

                                              <asp:Image ID="DirectionImage" runat="server" AlternateText="up" Style="display:none"/>                                                                            

                                        </ItemTemplate>

                                    </telerik:GridTemplateColumn>

                                </Columns>                                

                            </MasterTableView>

                             <PagerStyle AlwaysVisible="true" Mode="NextPrevAndNumeric"/>

                           <ClientSettings>                               

                                <%--<ClientEvents OnCommand="RGProducts_Command" OnDataBinding="RGProducts_RowDataBound"   />--%>

                                <ClientEvents OnCommand="function(){}" OnDataBinding="RGProducts_RowDataBound" />

                            </ClientSettings>

                        </telerik:RadGrid>

                    </div>

                </telerik:RadPane>

            </telerik:RadSplitter>

        </telerik:RadPane>

    </telerik:RadSplitter

</asp:Content>

[WebMethod]

    public IList<MyProduct> GetRecommendedProducts(int ProductId)

    {

        IList<MyProduct> ProductList = new List<MyProduct>();

        ProductList = _productController.GetRecommendedProducts(ProductId);

        return ProductList;

    }

    [WebMethod(EnableSession = true)]

    public IList<MyProduct> GetProductsByCategoryId(int? CategoryId, int ProductId)

    {

        IList<MyProduct> ProductList = new List<MyProduct>();

        ProductList = _productController.GetProductListByCategoryId(CategoryId, ProductId);

 

        return ProductList;

    }

[DataObjectMethod(DataObjectMethodType.Select)]

    public IList<MyProduct> GetProductListByCategoryId(int? CategoryId, int ProductId)

    {

        IList<MyProduct> result = HttpContext.Current.Cache["ProductsByCategory"] as IList<MyProduct>;

        if (result == null)

        {

            SqlCacheDependency dependency;

            result = _productDao.GetProductsByCategoryId(CategoryId,ProductId, out dependency);

            result.Select(

            x =>

            {

                x.ProductImageUrl = ImageServerUrl + x.ProductSku + "/" + _ImageFile ?? "~/Images/OK_image.gif";

                return x;

            }).ToList();

            HttpContext.Current.Cache.Insert("ProductsByCategory", result, dependency, DateTime.Now.AddMinutes(_ComboCachDuration), TimeSpan.Zero);

        }

        return result;       

    }

 

    [DataObjectMethod(DataObjectMethodType.Select)]

    public IList<MyProduct> GetRecommendedProducts(int productId)

    {

        IList<MyProduct> result = HttpContext.Current.Cache["RecommendedProducts"] as IList<MyProduct>;

        if (result == null)

        {

            SqlCacheDependency dependency;

            result = _productDao.GetRecommendedProducts(productId, out dependency);

            result.Select(

            x =>

            {

                x.ProductImageUrl = ImageServerUrl + x.ProductSku + "/" + _ImageFile ?? "~/Images/OK_image.gif";

                return x;

            }).ToList();

            HttpContext.Current.Cache.Insert("RecommendedProducts", result, dependency, DateTime.Now.AddMinutes(_ComboCachDuration), TimeSpan.Zero);

        }

        return result;

    }

public IList<MyProduct> GetProductsByCategoryId(int? CategoryId,int ProductId,out SqlCacheDependency dependency)

    {

        string cmd = "";

        cmd = @"Select p.Product_ID,p.Name as [ProductName],p.SKU,p.Image1 From dbo.Table2 p Where p.Category_ID = " + CategoryId + " AND  p.Product_ID NOT IN (SELECT o.ObjectType2 FROM dbo.Table1 o WHERE o.ObjectType1 = " + ProductId + ")";

        DataTable dt = GetDataTable(cmd, Web2ConnString, out dependency, "Products");

        IList<MyProduct> ProductList = MakeProductsByCategory(dt);

        return ProductList;

    }

 

    private static IList<MyProduct> MakeProductsByCategory(DataTable dt)

    {

        var ProductList = new List<MyProduct>();

 

        foreach (DataRow row in dt.Rows)

        {

            if (ProductList.Any(x => x.ProductId == (int)row["Product_ID"]))

            {

                if (ProductList.Any(x => x.IsMainProduct == false) && ProductList.Any(x => x.IsSubProduct == true) && dt.Columns.Contains("IsMainProduct"))

                {

                    if (Convert.ToBoolean(row["IsMainProduct"]) == true)

                    {

                        ProductList.RemoveAt(ProductList.Count - 1);

                         var product = new Product();

                        product.ProductId = (int)row["Product_ID"];

                        product.ProductSku = row["SKU"].ToString();

                        product.ProductName = row["ProductName"].ToString();

                        product.ProductImageUrl = row["Image1"].ToString();

                        if (dt.Columns.Contains("IsMainProduct"))

                        {

                            product.IsMainProduct = true;

                        }

                        if (dt.Columns.Contains("IsSubProduct"))

                        {

                            product.IsSubProduct = true;

                        }

                        ProductList.Add(product);

                    }

                }

            }

            else

            {

                // Add new product in to list if not exists

                var product = new Product();

                product.ProductId = (int)row["Product_ID"];

                product.ProductSku = row["SKU"].ToString();

                product.ProductName = row["ProductName"].ToString();

                product.ProductImageUrl = row["Image1"].ToString();

                if (dt.Columns.Contains("IsMainProduct"))

                {

                    product.IsMainProduct = Convert.ToBoolean(row["IsMainProduct"]);

                }

                if (dt.Columns.Contains("IsSubProduct"))

                {

                    product.IsSubProduct = Convert.ToBoolean(row["IsSubProduct"]);

                }

                ProductList.Add(product);

            }

        }

 

        return ProductList;

    }

 

    public IList<MyProduct> GetRecommendedProducts(int productId, out SqlCacheDependency dependency)

    {

        string cmd = "";

        cmd = @"SELECT Product_ID,Name as [ProductName],SKU,Image1,CASE WHEN (o.ObjectType1 = " + productId + ") THEN 'TRUE' ELSE 'FALSE' END AS [IsMainProduct],"+

               "CASE WHEN (o.ObjectType2 = " + productId + ") THEN 'TRUE' ELSE 'FALSE' END AS [IsSubProduct] FROM dbo.Table2 p " +

               "INNER JOIN Table1 o ON p.Product_ID = o.ObjectType2 WHERE o.ObjectType1 = " + productId +

               " UNION " +

               "SELECT Product_ID,Name as [ProductName],SKU,Image1,CASE WHEN (o.ObjectType1 = " + productId + ") THEN 'TRUE' ELSE 'FALSE' END AS [IsMainProduct]," +

               "CASE WHEN (o.ObjectType2 = " + productId + ") THEN 'TRUE' ELSE 'FALSE' END AS [IsSubProduct] FROM dbo.Table2 p " +

               "INNER JOIN Table1 o ON p.Product_ID = o.ObjectType1 WHERE o.ObjectType2 = " + productId +

               "";

 

        DataTable dt = GetDataTable(cmd, Web2ConnString, out dependency, "Products");

        IList<MyProduct> ProductList = MakeProductsByCategory(dt);

        return ProductList;

    }

 

    public void InsertRecommendedProduct(int parentProductId, int childProductId)

    {

        string sql = @"INSERT INTO dbo.Table1

                       (

                        Object_ID1,

                        ObjectType1,

                        Object_ID2,

                        ObjectType2

                        )

                        VALUES

                        (

                        @Object_ID1,

                        @ObjectType1,

                        @Object_ID2,

                        @ObjectType2

                        )";

 

        var list = new List<SqlParameter>(4);

        var sqlParameter = new SqlParameter("Object_ID1", SqlDbType.Int);

        sqlParameter.Value = 0; // Hard Coded Value

        list.Add(sqlParameter);

        sqlParameter = new SqlParameter("ObjectType1", SqlDbType.Int);

        sqlParameter.Value = parentProductId;

        list.Add(sqlParameter);

        sqlParameter = new SqlParameter("Object_ID2", SqlDbType.Int);

        sqlParameter.Value = 0; // Hard Coded Value

        list.Add(sqlParameter);

        sqlParameter = new SqlParameter("ObjectType2", SqlDbType.Int);

        sqlParameter.Value = childProductId;

        list.Add(sqlParameter);

 

        ExecuteNonQuery(sql, Web2ConnString, list);

    }

 

    public void DeleteRecommendedProduct(int parentProductId, int childProductId)

    {

        string sql = @"DELETE dbo.Table1 WHERE ObjectType1 = @ObjectType1 AND ObjectType2 = @ObjectType2";

 

        var list = new List<SqlParameter>(2);

        var sqlParameter = new SqlParameter("ObjectType1", SqlDbType.Int);

        sqlParameter.Value = parentProductId;

        list.Add(sqlParameter);      

        sqlParameter = new SqlParameter("ObjectType2", SqlDbType.Int);

        sqlParameter.Value = childProductId;

        list.Add(sqlParameter);

 

        ExecuteNonQuery(sql, Web2ConnString, list);

    }

Radoslav
Telerik team
 answered on 01 Nov 2010
1 answer
133 views
Hi
I am trying to create a order form and order submit with the help of Rad Grid.
Can anybody tell me how can i create row on run time means.
here on page load display a blank radGrid then.
i am using a button Add Item for displaying a blank row and increase rows as per user input. untill user make all required item entry how can i do that.
i have find lot of support from many site but i am unable to reach our goad.
Shinu
Top achievements
Rank 2
 answered on 01 Nov 2010
2 answers
101 views
Hello.Suppose a scenario where all the data appear in the grid(they are loaded in server-side).
Is it possible via Grid to group/sort etc without calling any web-services,page methods or postbacks etc ?
Thank you in advance!
tasos
Top achievements
Rank 1
 answered on 01 Nov 2010
Narrow your results
Selected tags
Tags
+? more
Top users last month
Marco
Top achievements
Rank 4
Iron
Iron
Iron
Hiba
Top achievements
Rank 1
Iron
Iron
Rob
Top achievements
Rank 3
Bronze
Bronze
Iron
Max
Top achievements
Rank 1
Veteran
Iron
Alina
Top achievements
Rank 1
Want to show your ninja superpower to fellow developers?
Top users last month
Marco
Top achievements
Rank 4
Iron
Iron
Iron
Hiba
Top achievements
Rank 1
Iron
Iron
Rob
Top achievements
Rank 3
Bronze
Bronze
Iron
Max
Top achievements
Rank 1
Veteran
Iron
Alina
Top achievements
Rank 1
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?