Telerik Forums
UI for ASP.NET AJAX Forum
2 answers
361 views
Hello,

I'm trying to use radbuttons in a dotnetnuke install and I'm having trouble. The button keeps getting the default css classes even though I have all of these: EnableEmbeddedBaseStylesheet="false" EnableBrowserButtonStyle="false" EnableTheming="false" EnableAjaxSkinRendering="false"

Is there something I'm missing? Is there no way to get it to stop putting the "RadButton RadButton_Default rbLinkButton" into the class for the outputed div?

I am mostly just using the button for the single-click option - otherwise, I just want it to work like a normal linkbutton.

Thanks,

Mike
Mike
Top achievements
Rank 1
 answered on 29 Nov 2012
3 answers
812 views

On webpage load, I populate a RadComboBox with text and keys. I have a default value I assign then on server-side too.

If they click a button to clear the form, I blank out all controls, but populate defaults. I need to do it client-side, and I'm having trouble with RadComboBox. I thought I'd populate a hidden field with the RadComboBox's default text on server-side during the load, then assign that value client-side when needed. I've tried both set_text (and set_value with the hidden field holding the default value instead) but when it evaluates later, it appears either the text is right but the value isn't, or vice versa.

Do I have to track in 2 hidden fields (both  default text and default value) and assign both client-side? That seems goofy, but if so, in what order should it be done? Or can I do this without tracking both the text and value default?

Example javascript code would be very welcome, assuming the hidden fields are populated... unless I should do it a completely different way.

Nencho
Telerik team
 answered on 29 Nov 2012
2 answers
745 views
Hello all,

I have a radgrid which uses edit form templates. The grid has too many fields so I cannot use in-line edit mode (which I have a much better understanding of ) and I need to use edit form template instead. Basically when the grid opens I set every row to edit mode then I hide the databound columns. The only reason I actually have them is so I can set filters at the top of the Grid. My problem is that I need to change some textboxes in a specific "record" without doing a postback but I cannot seem to figure out how to access these textbox's.
I have a couple drop downs that when they are changed I need them to change textboxes to other values. I believe once I figure this out I will be able to figure out how to loop through all the data for my saves. Although some code for the save/add new buttons are there and also in the .vb code for update, I haven't programmed these yet so they can be ignored as it is not my concern at the moment.

Can anyone steer me in the right direction or have any insight? I will paste all my code below
Also, on render I am hiding the item template and showing only the edit template with item.Display = false. Is this the proper way to go about this as well?

I appreciate any help or direction.

Thanks,
ASPx code:
<%@ Page Title="" Language="VB" MasterPageFile="~/MasterNoBanner.master" AutoEventWireup="false" CodeFile="CropProtectionTransactions.aspx.vb" Inherits="CP_Transactions" %>
 
<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
 
<asp:Content ID="Content1" ContentPlaceHolderID="cphBodyText" Runat="Server">
    <div style="width: 980px; clear: both; border-bottom: 0px solid black;" >
 
        
        <telerik:RadCodeBlock ID="RadCodeBlock1" runat="server">
 
            <script type="text/javascript">
                function CatchKeyPress(sender, args) {
                    if (args.get_keyCode() == 13) { //Enter Key
                        var e = args.get_domEvent().rawEvent;
                        e.returnValue = false;
                        e.cancelBubble = true;
                        if (e.stopPropagation) {
                            e.preventDefault();
                            e.stopPropagation();
                        }
                    }
 
                    if (args.get_keyCode() == 27) { //esca Key
                        var e = args.get_domEvent().rawEvent;
                        e.returnValue = false;
                        e.cancelBubble = true;
                        if (e.stopPropagation) {
                            e.preventDefault();
                            e.stopPropagation();
                        }
                    }
                    if (args.get_keyCode() == 8 || args.get_keyCode() == 46) { //backspace Key
                        var e = args.get_domEvent().rawEvent;
                        e.returnValue = false;
                        e.cancelBubble = true;
                        if (e.stopPropagation) {
                            e.preventDefault();
                            e.stopPropagation();
                        }
                    }
 
                }
 
                function gridCommand(sender, args) {
                    var command = args.get_commandName();
                    if (command == "DeleteRow" || command == "CopyPaste" || command == "SaveChanges" || command == "CancelChanges" || command == "Sort" || command == "Page" || command == "Filter" || command == "ChangePageSize") {
                        //cancel the additional check in body.onunload
                        window.editInProgress = false;
                    }
                }
                function gridCommandCustom(evt) {
                    var command = evt
                    if (command == "DeleteRow" || command == "CopyPaste" || command == "SaveChanges" || command == "CancelChanges" || command == "Sort" || command == "Page" || command == "Filter" || command == "ChangePageSize" || command == "AddRecord") {
                        //cancel the additional check in body.onunload
                        window.editInProgress = false;
                    }
                }
                function verifyCancelChanges() {
                    if (window.editInProgress) {
                        //alert(window.editInProgress.tostring);
                        $find("<%=RadAjaxManager1.ClientID %>").ajaxRequest();
                    }
 
                }
                function updateEdit() {
                    window.editInProgress = true;
                }
                window.onbeforeunload = function (evt) {
                    // alert(window.editInProgress);
                    verifyCancelChanges();
 
                }
                function ddlProductChanged(sender, eventArgs) {
                    //This is where I need to update the other two fields
                                        
               }
 
 
               </script>
 
        </telerik:RadCodeBlock>
            <telerik:RadWindowManager runat="server" ID="RadWindowManager1">
    </telerik:RadWindowManager>
         <telerik:RadFormDecorator ID="RadFormDecorator1" runat="server" DecoratedControls="Default,Select,Textbox"
        EnableRoundedCorners="false" />
 
 
    <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server" OnAjaxRequest="RadAjaxManager1_AjaxRequest">
        <AjaxSettings>
                    <telerik:AjaxSetting AjaxControlID="RadAjaxManager1">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="RadGrid1" LoadingPanelID="RadAjaxLoadingPanel1"  />
                    <telerik:AjaxUpdatedControl ControlID="Label1" />
                </UpdatedControls>
            </telerik:AjaxSetting>
 
 
        </AjaxSettings>
    </telerik:RadAjaxManager>
    <telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" runat="server" Height="16px"
            Width="16px" />
 
<asp:Label id="Label1" runat="server" Text="asdf" Visible="false"></asp:Label>
 
        <telerik:RadGrid ID="RadGrid1" DataSourceID="SqlDataSource1"
            ShowStatusBar="True"  AllowFilteringByColumn="True"
            AllowSorting="True"   GridLines="None"  runat="server"
            AutoGenerateColumns="False" CellSpacing="0" AllowMultiRowEdit="True"
            Height="800px" Width="98%" PageSize="3"  AllowPaging="True">
            <ClientSettings>
             
<Selecting AllowRowSelect="True"></Selecting>
 
<ClientEvents OnKeyPress="CatchKeyPress"></ClientEvents>
 
            <Scrolling AllowScroll="true" UseStaticHeaders="true"></Scrolling>
        </ClientSettings>
         
 
            <MasterTableView EditMode="EditForms" DataKeyNames="TransactionID" DataSourceID="SqlDataSource1" CommandItemDisplay="Top"  PagerStyle-AlwaysVisible="true" InsertItemDisplay="Top" InsertItemPageIndexAction="ShowItemOnCurrentPage"  >
             
                <CommandItemTemplate>
                 
          <table width="100%">
          <tr>
            <td align="right"><asp:LinkButton ID="btnInsertProduct" OnClientClick="gridCommandCustom('AddRecord')" runat="server" CommandName="InsertProduct" Visible="true"><img style="border:0px" alt="" src="Images/AddRecord.gif" />- Add New Product</asp:LinkButton>        
            <asp:LinkButton ID="btnCancelChanges" runat="server" OnClientClick="gridCommandCustom('CancelChanges');" CommandArgument="CancelChanges" CommandName="CancelChanges" Visible="true"><img style="border:0px" alt="" src="Images/Cancel.gif" />- Clear all Changes </asp:LinkButton>      
 <asp:LinkButton ID="btnSaveChanges" runat="server" CommandArgument="SaveChanges" CommandName="SaveChanges"  OnClientClick="gridCommandCustom('SaveChanges');" Visible="true"><img style="border:0px" alt="" src="Images/Update.gif" />- Save All changes</asp:LinkButton>
 
 </td>
          </tr>
          </table>              
  
             
            </CommandItemTemplate>
<CommandItemSettings ExportToPdfText="Export to PDF"></CommandItemSettings>
 
<RowIndicatorColumn Visible="false" FilterControlAltText="Filter RowIndicator column"></RowIndicatorColumn>
 
<ExpandCollapseColumn Visible="false" FilterControlAltText="Filter ExpandColumn column"></ExpandCollapseColumn>
     
    <Columns>
     
                    <telerik:GridBoundColumn DataField="TransactionID"
            FilterControlAltText="Filter TransactionID column" HeaderText="TransactionID"
            SortExpression="TransactionID" UniqueName="TransactionID" DataType="System.Int32" ReadOnly="True" Visible="false">
        </telerik:GridBoundColumn>
                                <telerik:GridDropDownColumn UniqueName="MemberID" SortExpression="MemberID" HeaderText="Company Name" DataSourceID="dsMembers" DataField="MemberID"
                  ListTextField="CompanyName" ListValueField="MemberID" AllowAutomaticLoadOnDemand="false"  DropDownControlType="radcombobox" FilterControlWidth="150px" autopostbackonfilter="true" EmptyListItemText="Select ..."  showfiltericon="false" > <HeaderStyle Width="125px" /><ItemStyle Width="125px"  />
                                    <FilterTemplate>
                        <telerik:RadComboBox ID="RadComboBoxMembers" DataSourceID="dsMembers" DataTextField="CompanyName"
                            DataValueField="MemberID" Height="200px" AppendDataBoundItems="true" MarkFirstMatch="true" AllowCustomText="false" SelectedValue='<%# TryCast(Container,GridItem).OwnerTableView.GetColumn("MemberID").CurrentFilterValue %>'
                            runat="server" OnClientSelectedIndexChanged="MemberIndexChanged" Width="90%" DropDownWidth="350px">
                            <Items>
                                <telerik:RadComboBoxItem Text="All" />
                            </Items>
                        </telerik:RadComboBox>
                        <telerik:RadScriptBlock ID="RadScriptBlockMembers" runat="server">
                            <script type="text/javascript">
                                function MemberIndexChanged(sender, args) {
                                    var tableView = $find("<%# TryCast(Container,GridItem).OwnerTableView.ClientID %>");
                                    tableView.filter("MemberID", args.get_item().get_value(), "EqualTo");
                                }
                            </script>
                        </telerik:RadScriptBlock>
                    </FilterTemplate>
                   
                  </telerik:GridDropDownColumn>
                <telerik:GridTemplateColumn DataField="ShipTo" FilterControlAltText="Filter ShipTo column" HeaderText="Ship To" ShowFilterIcon="false"
        UniqueName="ShipTo" SortExpression="ShipTo" ItemStyle-Height="0px">
         
        </telerik:GridTemplateColumn>
                        <telerik:GridTemplateColumn DataField="PurchaseDate" FilterControlAltText="Filter PurchaseDate column" HeaderText="Purchase Date " ShowFilterIcon="false"
        UniqueName="PurchaseDate" SortExpression="PurchaseDate" ItemStyle-Height="0px">
         
        </telerik:GridTemplateColumn>
                          <telerik:GridTemplateColumn DataField="DistributorName" FilterControlAltText="Filter DistributorName column" HeaderText="Distributor Name" ShowFilterIcon="false"
        UniqueName="DistributorName" SortExpression="DistributorName" ItemStyle-Height="0px">
         
        </telerik:GridTemplateColumn>
                                <telerik:GridDropDownColumn UniqueName="CPProductID" SortExpression="CPProductID" HeaderText="Supplier" DataSourceID="dsProducts" DataField="CPProductID"
                  ListTextField="Product" ListValueField="CPProductID" AllowAutomaticLoadOnDemand="false"  DropDownControlType="radcombobox" FilterControlWidth="150px" autopostbackonfilter="true" EmptyListItemText="Select ..."  showfiltericon="false" > <HeaderStyle Width="225px" /><ItemStyle Width="225px"  />
                                    <FilterTemplate>
                        <telerik:RadComboBox ID="RadComboboxProduct" DataSourceID="dsProducts" DataTextField="Product"
                            DataValueField="CPProductID" Height="200px" AppendDataBoundItems="true" MarkFirstMatch="true" AllowCustomText="false" SelectedValue='<%# TryCast(Container,GridItem).OwnerTableView.GetColumn("CPProductID").CurrentFilterValue %>'
                            runat="server" OnClientSelectedIndexChanged="ProductIndexChanged">
                            <Items>
                                <telerik:RadComboBoxItem Text="All" />
                            </Items>
                        </telerik:RadComboBox>
                        <telerik:RadScriptBlock ID="RadScriptBlock1" runat="server">
                            <script type="text/javascript">
                                function ProductIndexChanged(sender, args) {
                                    var tableView = $find("<%# TryCast(Container,GridItem).OwnerTableView.ClientID %>");
                                    tableView.filter("CPProductID", args.get_item().get_value(), "EqualTo");
 
                                }
                            </script>
                        </telerik:RadScriptBlock>
                    </FilterTemplate>
                   
                  </telerik:GridDropDownColumn>
 
        
    </Columns>
    <EditFormSettings EditFormType="Template" >
                    <FormTemplate>
                     <div><br />
                        <table style="margin-left: 5px;" width="99%">
                          <tr valign="top">
                            <td width="150px"><asp:Label ID="lblCompanyName" runat="server" Text="Member" Font-Bold="true"></asp:Label></td>
                            <td width="120px"><asp:Label ID="lblShipTop" runat="server" Text="Ship To" Font-Bold="true"></asp:Label></td>
                            <td ><asp:Label ID="lblPurchaseDate" runat="server" Text="Purchase Date" Font-Bold="true"></asp:Label></td>
                          </tr>
                          <tr valign="top">
                            <td>                            <telerik:RadComboBox ID="ddlMember" runat="server" AppendDataBoundItems="true" AutoPostBack="true"
                                                        EmptyMessage="Select..." DataSourceID="dsMembers" DataTextField="CompanyName"  DataValueField="MemberID" SelectedValue='<%# Bind("MemberID") %>' MarkFirstMatch="true" DropDownWidth="400px" HighlightTemplatedItems="true" Width="200px" Height="250px" OnSelectedIndexChanged="ddlMember_SelectedIndexChanged"  ClientEvents-OnKeyPress="KeyPressed" EnableLoadOnDemand="false" >
                            <HeaderTemplate>
                                                            <ul>
                                                                <li class="colCompanyName">Company Name</li>
                                                                <li class="colCPMember">CP Member</li>                                                               
                                                             </ul>
                                                             
                                                        </HeaderTemplate>
                                                        <ItemTemplate>
                                                            <ul>
                                                                <li class="colCompanyName"><%# Eval("CompanyName")%></li>
                                                                <li class="colCPMember" ><%# Eval("CPMember")%></li>
                                                            </ul>
                                                        </ItemTemplate>
                             
                            </telerik:RadComboBox></td>
                            <td>
                                <telerik:RadComboBox ID="ddlShipTo" runat="server" AppendDataBoundItems="false"
                                datatextfield="ShipTo" DataValueField="ShipToID"
                                MarkFirstMatch="true" DropDownWidth="200px" HighlightTemplatedItems="true" Width="200px"
                                 ClientEvents-OnKeyPress="KeyPressed" ></telerik:RadComboBox>
 
 
                            </td>
                <td><telerik:RadDatePicker ID="txtPurchaseDate" runat="server"  ClientEvents-OnKeyPress="KeyPressed" Width="140px"   AutoPostBack="false"
                        DateInput-EmptyMessage="" MinDate="01/01/1000" MaxDate="01/01/3000" SelectedDate='<%# Bind("PurchaseDate") %> '>
                        <Calendar ID="Calendar1" runat="server"  ClientEvents-OnKeyPress="KeyPressed">
                            <SpecialDays>
                                <telerik:RadCalendarDay Repeatable="Today" ItemStyle-CssClass="rcToday" />
                            </SpecialDays>
                        </Calendar>
                    </telerik:RadDatePicker></td>
                          </tr>
                          <tr>
                            <td colspan="3" align="center">
                                <table width="100%" border="0" cellpadding="1" cellspacing="0">
                                    <tr>
                                        <td width="175px" align="left"><asp:Label ID="Label8" runat="server" Text="Distributor" Font-Bold="true"></asp:Label></td>
                                        <td width="100px" align="left"><asp:Label ID="Label9" runat="server" Text="Invoice #" Font-Bold="true"></asp:Label></td>
                                        <td width="175px" align="left"><asp:Label ID="Label16" runat="server" Text="Product" Font-Bold="true"></asp:Label></td>
                                        <td width="75px" align="left"><asp:Label ID="Label17" runat="server" Text="Size" Font-Bold="true"></asp:Label></td>
                                        <td width="150px" align="left"><asp:Label ID="Label18" runat="server" Text="Manufacturer" Font-Bold="true"></asp:Label></td>
                                        <td  width="75px" align="left"><asp:Label ID="Label19" runat="server" Text="Quantity" Font-Bold="true"></asp:Label></td>
                                        <td  width="75px" align="left"><asp:Label ID="Label20" runat="server" Text="Price" Font-Bold="true"></asp:Label></td>
                                        <td  width="75px" align="left"><asp:Label ID="Label21" runat="server" Text="Extension" Font-Bold="true"></asp:Label></td>
                                    </tr>
                                </table>
                                 
                            </td>
                          </tr>
                          <tr>
                            <td colspan="3" align="center">
                                <table width="100%" border="0" cellpadding="1" cellspacing="0">
                                    <tr>
                                        <td width="175px" align="left"><telerik:RadComboBox ID="ddlDistributors" runat="server" AppendDataBoundItems="false" AutoPostBack="false"
                                                        EmptyMessage="Select..." DataSourceID="dsDistributors" DataTextField="DistributorName"  DataValueField="CPDistributorID" SelectedValue='<%# Bind("CPDistributorID") %>' MarkFirstMatch="true" DropDownWidth="200px" HighlightTemplatedItems="true" Width="175px" Height="250px"   ClientEvents-OnKeyPress="KeyPressed" ></telerik:RadComboBox>
                                        </td>
                                        <td width="100px" align="left">
                                            <telerik:RadTextBox ID="txtInvoiceNumber" Text='<%# Bind("InvoiceNumber") %>' runat="server" width="90px"></telerik:RadTextBox>
                                        </td>
                                        <td width="175px" align="left"><telerik:RadComboBox ID="ddlProduct" runat="server" AppendDataBoundItems="false" AutoPostBack="false"
                                                        EmptyMessage="Select..." DataSourceID="dsProducts" DataTextField="Product"  DataValueField="CPProductID" SelectedValue='<%# Bind("CPProductID") %>' MarkFirstMatch="true" DropDownWidth="500px" HighlightTemplatedItems="true" Width="175px" Height="250px"   ClientEvents-OnKeyPress="KeyPressed"  OnItemDataBound="ddlProduct_ItemDataBound"  EnableLoadOnDemand="false" >
                                                        <HeaderTemplate>
                                                            <ul>
                                                                <li class="colProductName">Product Name</li>
                                                                <li class="colSize">Pkg Size</li>                                                               
                                                                <li class="colSuppleer">Manufacturer</li>                                                               
                                                             </ul>
                                                             
                                                        </HeaderTemplate>
                                                        <ItemTemplate>
                                                            <ul>
                                                                <li class="colProductName"><%# Eval("Product")%></li>
                                                                <li class="colSize" ><%# Eval("Size")%></li>
                                                                <li class="colSuppleer"><%# Eval("SupplierName")%></li>  
                                                            </ul>
                                                        </ItemTemplate>
                                                        </telerik:RadComboBox></td>
                                        <td width="75px" align="left"><telerik:RadTextBox ID="txtSize" runat="server" ReadOnly="true" Width="75px"></telerik:RadTextBox></td>
                                        <td width="150px" align="left"><telerik:RadTextBox ID="txtManufacturer" runat="server" ReadOnly="true" Width="150px"></telerik:RadTextBox></td>
                                        <td width="75px" align="left"><telerik:RadNumericTextBox incrementsettings-interceptarrowskeys="false" incrementsettings-interceptmousewheel="false"  ID="txtQuantity" NumberFormat-DecimalDigits="3"  runat="server" Type="number" width="100%" NumberFormat-GroupSeparator="" invalidstyleduration="100" Dbvalue='<%# Bind("Quantity") %>' > </telerik:RadNumericTextBox></td>
                                        <td width="75px" align="left"><telerik:RadNumericTextBox incrementsettings-interceptarrowskeys="false" incrementsettings-interceptmousewheel="false"  ID="txtPrice" runat="server" Type="currency" width="100%" EmptyMessageStyle-Width="70px"  Dbvalue='<%# Bind("Price") %>'></telerik:RadNumericTextBox></td>
                                        <td width="75px" align="left"><telerik:RadNumericTextBox incrementsettings-interceptarrowskeys="false" incrementsettings-interceptmousewheel="false"  ID="txtExtension" runat="server" Type="currency" width="100%" EmptyMessageStyle-Width="70px"  Dbvalue='<%# Bind("Extension") %>'  NumberFormat-NegativePattern="$- n"></telerik:RadNumericTextBox></td>
                                    </tr>
                                </table>
                                 
                            </td>
                          </tr>
                           
                        </table><br /></div>
                    </FormTemplate>
</EditFormSettings>
</MasterTableView>
        <ClientSettings AllowKeyboardNavigation="false">
         
         <ClientEvents OnKeyPress="CatchKeyPress" OnCommand="gridCommand" ></ClientEvents>
          
                         <Selecting AllowRowSelect="true" />
                                              <Scrolling AllowScroll="true"  UseStaticHeaders="true" />
        </ClientSettings>
        <GroupingSettings CaseSensitive="false" />
        <EditItemStyle />
                      <AlternatingItemStyle BackColor="Aqua" />
                       
 
<FilterMenu EnableImageSprites="False"></FilterMenu>
        </telerik:RadGrid>
 
            <asp:SqlDataSource ID="SqlDataSource1" runat="server"
            ConnectionString="<%$ ConnectionStrings:csPrairielandAg %>"
            ProviderName="<%$ ConnectionStrings:csPrairielandAg.ProviderName %>"
            SelectCommand="select TransactionID, a.MemberID,a.ShipToID,  PurchaseDate, a.CPDistributorID, InvoiceNumber,a.CPProductID, Product, Quantity, Price, Extension, NetPricing, DPS,e.CPSupplierID from tblCropProtectionTransactions a join tblMembers b on a.MemberID = b.MemberID join tblMembershipto c on a.ShipToID = c.ShipToId join tblCropProtectionDistributors d on a.CPDistributorID = d.CPDistributorID join tblCropProtectionProducts e on a.CPProductID = e.CPProductID join tblCropProtectionSuppliers f on e.CPSupplierID = f.CPSupplierID where DateDiff(month,PurchaseDate,getdate()) < 24 ORDER BY PurchaseDate, CompanyName"
            UpdateCommand="UPDATE dbo.tblCropProtectionDistributors SET DistributorName = @DistributorName WHERE (CPDistributorID = @CPDistributorID)"
            InsertCommand="INSERT INTO dbo.tblCropProtectionDistributors(DistributorName) VALUES ( @DistributorName)">
                <InsertParameters>
                    <asp:Parameter Name="DistributorName" />
                </InsertParameters>
            <UpdateParameters>
                <asp:Parameter Name="CPDistributorID" />
                <asp:Parameter Name="DistributorName" />
            </UpdateParameters>
        </asp:SqlDataSource>
 
            <asp:SqlDataSource ID="dsSupplier" runat="server"
            ConnectionString="<%$ ConnectionStrings:csPrairielandAg %>"
            ProviderName="<%$ ConnectionStrings:csPrairielandAg.ProviderName %>"
            SelectCommand="SELECT CPSupplierID, SupplierName FROM dbo.tblCropProtectionSuppliers" >
        </asp:SqlDataSource>
 <asp:SqlDataSource ID="dsProducts" runat="server"
            ConnectionString="<%$ ConnectionStrings:csPrairielandAg %>"
            ProviderName="<%$ ConnectionStrings:csPrairielandAg.ProviderName %>"
            SelectCommand="SELECT CPProductID,Product,Size,SupplierName from tblCropProtectionProducts a join tblCropProtectionSuppliers b on a.CPSupplierID = b.CPSupplierID
order by PRoduct,Size,SupplierName" >
        </asp:SqlDataSource>
 <asp:SqlDataSource ID="dsDistributors" runat="server"
            ConnectionString="<%$ ConnectionStrings:csPrairielandAg %>"
            ProviderName="<%$ ConnectionStrings:csPrairielandAg.ProviderName %>"
            SelectCommand="select CPDistributorID, DistributorName from tblCropProtectionDistributors order by DistributorName" >
 
        </asp:SqlDataSource>
            <asp:SqlDataSource ID="dsMembers" runat="server"
            ConnectionString="<%$ ConnectionStrings:csPrairielandAg %>"
            ProviderName="<%$ ConnectionStrings:csPrairielandAg.ProviderName %>"
            SelectCommand="SELECT distinct tblMembers.MemberId, tblMembers.CompanyName, tblMembers.Email, case [CropProtection] when 1 then 'Yes' when 0 then 'No' end AS [CPMember] FROM tblMembers ORDER BY tblMembers.CompanyName" >
 
        </asp:SqlDataSource>
                    <asp:SqlDataSource ID="dsShipTo" runat="server"
            ConnectionString="<%$ ConnectionStrings:csPrairielandAg %>"
            ProviderName="<%$ ConnectionStrings:csPrairielandAg.ProviderName %>"
            SelectCommand="SELECT ShipToId, ShipTo from tblMemberShipTo where MemberID = @MemberID order by IsDefault desc, ShipTo asc">
            <SelectParameters>
               <asp:Parameter Name="MemberID" />
            </SelectParameters>                  
             
 
        </asp:SqlDataSource>
 
        <br />
            </div>
 
 
</asp:Content>

aspx.vb code:
Imports System
Imports System.Data
Imports System.Configuration
Imports System.Collections
Imports System.Web
Imports System.Web.Security
Imports System.Web.UI
Imports System.Web.UI.WebControls
Imports System.Web.UI.WebControls.WebParts
Imports System.Web.UI.HtmlControls
Imports Telerik.Web.UI
Imports System.Data.OleDb
Imports System.Data.SqlClient
Imports System.Collections.Generic
Imports System.Data.Common
Imports System.Diagnostics
Imports System.ComponentModel
Imports System.Web.SessionState
Imports System.Web.Mail
Imports System.Net.Mail
Imports System.Xml
Partial Public Class CP_Transactions
 
    Inherits System.Web.UI.Page
 
    Dim strMode As String = ""
    Protected Sub Page_Load(sender As Object, e As EventArgs) Handles Me.Load
        ' RadGrid1.Enabled = True
        RadGrid1.Visible = True
        Session("Refresh") = "Yes"
    End Sub
 
    Protected Sub RadGrid1_ItemCommand(sender As Object, e As Telerik.Web.UI.GridCommandEventArgs) Handles RadGrid1.ItemCommand
 
        If e.CommandName = "RefreshGrid" Then
            strMode = "Refresh"
            e.Item.OwnerTableView.Rebind()
        ElseIf e.CommandName = "SaveChanges" Then
            RadGrid1_UpdateCommand(sender, e)
            e.Item.OwnerTableView.Rebind()
            strMode = "Save"
 
        ElseIf e.CommandName = "CancelChanges" Then
            strMode = "Cancel"
            ' RadGrid1.EditIndexes.Clear()
            RadGrid1.MasterTableView.IsItemInserted = False
            For Each column As GridColumn In RadGrid1.MasterTableView.Columns
                column.CurrentFilterFunction = GridKnownFunction.NoFilter
                column.CurrentFilterValue = String.Empty
            Next
            RadGrid1.MasterTableView.FilterExpression = String.Empty
            e.Item.OwnerTableView.Rebind()
        ElseIf e.CommandName = "Sort" Then
            strMode = "Sort"
        ElseIf e.CommandName = "Page" Then
            strMode = "Page"
        ElseIf e.CommandName = "ChangePageSize" Then
            RadGrid1.EditIndexes.Clear()
        End If
        If e.CommandName = "DeleteRow" Then
            'Dim image As ImageButton = DirectCast(e.CommandSource, ImageButton)
            Dim strProductID = e.Item.OwnerTableView.DataKeyValues(e.Item.ItemIndex)("CPProductID").ToString
            'strProductID = Replace(strProductID, "Delete ", "")
            Try
                Dim deleteQuery As String = "Delete from tblCropProtectionProducts where CPProductID='" & strProductID & "'"
                Dim strConn As String = ConfigurationManager.ConnectionStrings("csPrairielandAg").ConnectionString
                Using connection As New SqlConnection(strConn)
                    connection.Open()
                    Using Command As New SqlCommand(deleteQuery, connection)
                        Command.CommandType = Data.CommandType.Text
                        Command.CommandText = deleteQuery
                        Command.ExecuteNonQuery()
                        SetMessage("Product deleted")
                    End Using
                    connection.Close()
                End Using
                RadGrid1.Rebind()
            Catch ex As Exception
                If InStr(ex.Message, "The DELETE statement conflicted with the REFERENCE constraint", CompareMethod.Text) > 0 Then
                    SetMessage("Cannot delete this Product as it is currently tied to a transaction.")
                Else
                    SetMessage(ex.Message)
                End If
 
 
            End Try
        End If
        If e.CommandName = "InsertProduct" Then
            RadGrid1.MasterTableView.IsItemInserted = True
            RadGrid1.Rebind()
        End If
 
    End Sub
 
    Protected Sub RadGrid1_PageIndexChanged(sender As Object, e As Telerik.Web.UI.GridPageChangedEventArgs) Handles RadGrid1.PageIndexChanged
        If RadGrid1.Items.Item(1).IsInEditMode = True Then
            e.Item.FireCommandEvent("Update", String.Empty)
        End If
 
    End Sub
 
    Protected Sub RadGrid1_PreRender(sender As Object, e As System.EventArgs) Handles RadGrid1.PreRender
        If Session("Refresh") = "No" Then
            Exit Sub
        End If
        For i As Integer = 0 To RadGrid1.Items.Count
            RadGrid1.EditIndexes.Add(i)
        Next
        RadGrid1.Rebind()
        For Each item As GridDataItem In RadGrid1.MasterTableView.Items
            If item.IsDataBound Then
                item.Display = False
            End If
        Next
        Label1.Visible = "False"
    End Sub
 
    Protected Sub RadGrid1_UpdateCommand(sender As Object, e As Telerik.Web.UI.GridCommandEventArgs) Handles RadGrid1.UpdateCommand
        If RadGrid1.MasterTableView.IsItemInserted = True Then
            Dim dataInsert As GridDataItem = e.Item.OwnerTableView.GetInsertItem
            Dim txtSupplier As RadComboBox = DirectCast(dataInsert("CPSupplierID").Controls(0), RadComboBox)
            Dim txtProduct As TextBox = DirectCast(dataInsert("Product").Controls(0), TextBox)
            Dim txtSize As TextBox = DirectCast(dataInsert("Size").Controls(0), TextBox)
            SqlDataSource1.InsertParameters("CPSupplierID").DefaultValue = txtSupplier.SelectedValue
            SqlDataSource1.InsertParameters("Size").DefaultValue = txtSize.Text
            SqlDataSource1.InsertParameters("Product").DefaultValue = txtProduct.Text
 
            Try
                SqlDataSource1.Insert()
                RadGrid1.MasterTableView.IsItemInserted = False
                Label1.Visible = False
                '  RadGrid1.EditIndexes.Clear()
            Catch ex As Exception
                SetMessage(Server.HtmlEncode("Unable to update Product. Reason: " + ex.StackTrace).Replace("'", "'").Replace(vbCrLf, "<br />"))
            End Try
        End If
 
        If RadGrid1.Items.Item(1).IsInEditMode = True Then
            For Each dataItem As GridDataItem In RadGrid1.MasterTableView.Items
                Dim newValues As New Hashtable()
                Dim eeditedItem As GridEditableItem = TryCast(e.Item, GridEditableItem)
                Dim intProductID As Integer = dataItem.OwnerTableView.DataKeyValues(dataItem.ItemIndex)("CPProductID")
                RadGrid1.MasterTableView.ExtractValuesFromItem(newValues, dataItem)
                SqlDataSource1.UpdateParameters("CPProductID").DefaultValue = intProductID
                SqlDataSource1.UpdateParameters("CPSupplierID").DefaultValue = newValues("CPSupplierID")
                SqlDataSource1.UpdateParameters("Product").DefaultValue = newValues("Product")
                SqlDataSource1.UpdateParameters("Size").DefaultValue = newValues("Size")
                Try
                    SqlDataSource1.Update()
                    RadGrid1.MasterTableView.IsItemInserted = False
                    Label1.Visible = False
                    '  RadGrid1.EditIndexes.Clear()
                Catch ex As Exception
                    SetMessage(Server.HtmlEncode("Unable to update Product. Reason: " + ex.StackTrace).Replace("'", "'").Replace(vbCrLf, "<br />"))
                End Try
            Next
 
        Else
            Exit Sub
        End If
 
    End Sub
    Private Sub SetMessage(ByVal message As String)
        Label1.Text = String.Format("<span style='color:red'>{0}</span>", message)
        Label1.Visible = True
    End Sub
 
    Protected Sub ddlProduct_ItemDataBound(sender As Object, e As RadComboBoxItemEventArgs)
        Dim row As DataRowView = TryCast(e.Item.DataItem, DataRowView)
        e.Item.Attributes("Product") = row("Product").ToString()
        e.Item.Attributes("Size") = row("Size").ToString()
        e.Item.Attributes("SupplierName") = row("SupplierName").ToString()
        'e.Item.Attributes.Add("onchange", "return ddlProductChanged('" + e.Item.ClientID + "',Null,Null, event);")
    End Sub
 
    Protected Sub ddlProduct_SelectedIndexChanged(o As Object, e As Telerik.Web.UI.RadComboBoxSelectedIndexChangedEventArgs)
        Dim editedItem As GridEditableItem = TryCast(TryCast(o, RadComboBox).NamingContainer, GridEditableItem)
        Dim productCombo As RadComboBox = TryCast(o, RadComboBox)
        'Dim  As RadComboBox = TryCast(editedItem.FindControl("ddlShipTo"), RadComboBox)
        'ddlShipTo.Text = ""
        'ddlShipTo.DataSource = LoadShipTo(e.Value)
        'ddlShipTo.DataBind()
        Dim txtSize As RadTextBox = TryCast(editedItem.FindControl("txtSize"), RadTextBox)
        Dim txtManufacturer As RadTextBox = TryCast(editedItem.FindControl("txtManufacturer"), RadTextBox)
        txtSize.Text = productCombo.SelectedItem.Attributes("Size").ToString
        txtManufacturer.Text = productCombo.SelectedItem.Attributes("SupplierName").ToString
        Session("Refresh") = "No"
    End Sub
    Protected Sub ddlMember_SelectedIndexChanged(o As Object, e As Telerik.Web.UI.RadComboBoxSelectedIndexChangedEventArgs)
        Dim editedItem As GridEditableItem = TryCast(TryCast(o, RadComboBox).NamingContainer, GridEditableItem)
        Dim membersCombo As RadComboBox = TryCast(o, RadComboBox)
        Dim ddlShipTo As RadComboBox = TryCast(editedItem.FindControl("ddlShipTo"), RadComboBox)
        ddlShipTo.Text = ""
        ddlShipTo.DataSource = LoadShipTo(e.Value)
        ddlShipTo.DataBind()
        Session("Refresh") = "No"
 
    End Sub
    Protected Function LoadShipTo(MemberID As String) As DataTable
        Dim connection As New SqlConnection(ConfigurationManager.ConnectionStrings("csPrairielandAg").ConnectionString)
 
        'select a country based on the continentID
        Dim adapter As New SqlDataAdapter("SELECT ShipToId, ShipTo from tblMemberShipTo where MemberId=@MemberID order by IsDefault desc, ShipTo asc", connection)
        adapter.SelectCommand.Parameters.AddWithValue("@MemberID", MemberID)
 
        Dim dt As New DataTable()
        adapter.Fill(dt)
 
        Return dt
    End Function
    Protected Sub RadGrid1_ItemDataBound(sender As Object, e As Telerik.Web.UI.GridItemEventArgs) Handles RadGrid1.ItemDataBound
        If TypeOf e.Item Is GridEditableItem AndAlso e.Item.IsInEditMode Then
            Dim editedItem As GridEditableItem = TryCast(e.Item, GridEditableItem)
 
            If e.Item.OwnerTableView.IsItemInserted Then
                Dim memberCombo As RadComboBox = TryCast(editedItem.FindControl("ddlMember"), RadComboBox)
                Dim shiptoCombo As RadComboBox = TryCast(editedItem.FindControl("ddlShipto"), RadComboBox)
 
                shiptoCombo.DataSource = LoadShipTo(memberCombo.SelectedValue)
                shiptoCombo.DataBind()
            Else
                Dim dataSourceRow As DataRowView = DirectCast(e.Item.DataItem, DataRowView)
                Dim memberCombo As RadComboBox = TryCast(editedItem.FindControl("ddlMember"), RadComboBox)
                Dim shiptoCombo As RadComboBox = TryCast(editedItem.FindControl("ddlShipto"), RadComboBox)
                shiptoCombo.DataSource = LoadShipTo(memberCombo.SelectedValue)
                shiptoCombo.DataBind()
                shiptoCombo.SelectedValue = dataSourceRow("ShipToID").ToString()
 
                Dim productCombo As RadComboBox = TryCast(editedItem.FindControl("ddlProduct"), RadComboBox)
                Dim txtSize As RadTextBox = TryCast(editedItem.FindControl("txtSize"), RadTextBox)
                Dim txtManufacturer As RadTextBox = TryCast(editedItem.FindControl("txtManufacturer"), RadTextBox)
                txtSize.Text = productCombo.SelectedItem.Attributes("Size").ToString
                txtManufacturer.Text = productCombo.SelectedItem.Attributes("SupplierName").ToString
            End If
        End If
 
    End Sub
 
 
End Class


ADT
Top achievements
Rank 1
 answered on 29 Nov 2012
8 answers
403 views
Hi,
I am selecting a date in RadDateTime Picker and I am validating selected date in OnDateSelected()  client event based on some validation i m clearing the textbox in RadDateTime Picker 1. But the problem is selected date is not clearing in RadDateTime Picker .

function

 

ValidateWithDtEntryDate(sender,e)

 

{

 

var datePicker2 = $find("<%= datepicker2.ClientID %>");
here i am doing validtion with datepicker2  and clearing textbox in  datepicker1 but the prblm is how to clear sellected date in datetimepicker1.
}

 

 

<telerik:RadDatePicker ID="datetimepicker1" runat ="server" >

 

 

 

 

 

<DateInput ID="DateInputSentQcDate" DateFormat="MM/dd/yyyy" style="color:Navy" ReadOnly ="true" runat ="server"></DateInput>

 

 

 

 

 

<ClientEvents OnDateSelected="ValidateWithDtEntryDate"  />

 

 

 

 

 

</telerik:RadDatePicker>

 

Eyup
Telerik team
 answered on 29 Nov 2012
2 answers
170 views
I have a very basic grid with the ability to add records directly to it.  When you click Add Record, you get a blank grid until a postback.  If you click the foo button, you'll see the grid comes back in add mode.  I tried adding an RadAjaxPanel and a RadAjaxManager, but neither fixed the issue. 

Help!

<%@ 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">
         
    </script>
    <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server">
        <AjaxSettings>
            <telerik:AjaxSetting AjaxControlID="cartgrdItems">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="cartgrdItems" />
                </UpdatedControls>
            </telerik:AjaxSetting>
        </AjaxSettings>
 
    </telerik:RadAjaxManager>
    <div>
    <telerik:RadAjaxPanel runat="server" ID="foo" EnableAJAX="true" ViewStateMode="Enabled">
        <telerik:RadGrid runat="server" ID="cartgrdItems">
            <MasterTableView EnableNoRecordsTemplate="true" CommandItemDisplay="Top" EditMode="InPlace">
                <CommandItemSettings ShowAddNewRecordButton="true" AddNewRecordText="Add Item" />               
            </MasterTableView>                   
        </telerik:RadGrid>
        <telerik:RadButton runat="server" ID="bar" text="foo" onclick="bar_Click" />   
        </telerik:RadAjaxPanel>
    </div>
    </form>
</body>
</html>


using System;
using System.Collections.Generic;
using System.Web.UI;
 
public partial class Default : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            List<ApprovalDetail> foo = new List<ApprovalDetail>();
            cartgrdItems.DataSource = new Object[0];
 
 
            cartgrdItems.DataSource = foo;
            cartgrdItems.DataBind();
        }
    }
 
    protected void bar_Click(object sender, EventArgs e)
    {
 
    }
     
    [Serializable]
    public class ApprovalDetail
    {
        public string PRNumber { get; set; }
        public int ItemNumber { get; set; }
        public string ItemNumberCode { get; set; }       
        public string ItemUOM { get; set; }
        public decimal ItemUnit { get; set; }
        public string ItemMatGroup { get; set; }
    }
}
Steven
Top achievements
Rank 1
 answered on 29 Nov 2012
2 answers
152 views
Hi !

I'm currently working on a website with asp.NET 4.0 and c#.
I need to implemente a User control in a listview. I want the listview to show a list of data from a table name Lignes (with a ligne_id as primary key) and the user control to show a list of data from a table name Blocks (with a block_id as primary key and a ligne_id as foreign key).

Here's the code I made :

My Listview :

<asp:ListView ID="ListView1" runat="server" DataKeyNames="ligne_id" DataSourceID="SqlDataSourceLigne">
    <ItemTemplate>
            <asp:Label ID="ligne_id" ClientIDMode="Static" runat="server" Text='<%# Eval("ligne_id") %>' />
            <uc1:UC_ListeBlock ID="UC_ListeBlock1" runat="server" Ligne_ID='<%# Eval("ligne_id") %>' />
    </ItemTemplate>
</asp:ListView>


My UserControl :

<asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>


My user control's code Behind :

public partial class UC_ListeBlock : System.Web.UI.UserControl
{
    public Int32 Ligne_ID;
 
    private Int32 ligne_ID
    {
        get { return Ligne_ID; }
        set { Ligne_ID = value; }
    }
 
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!Page.IsPostBack)
        {
            Label1.Text = ligne_ID.ToString();
        }
    }
}


When I execute this code, the label ligne_id from the listview has the good ligne_id from the database (so Text='<%# Eval("ligne_id") %>' is working) but the Label1 from the user control is always at 0 (so Ligne_ID='<%# Eval("ligne_id") %>' doesn't seem to work).

Do you have an idea what is wrong with my code ?

Thanks in advance for you awnser

P.S : I'm french so I'm sorry if I'm not very clear in my explanation.
Yann
Top achievements
Rank 1
 answered on 29 Nov 2012
6 answers
226 views
Dear Telerik team,

i have a grid with some extra icon column (GridImageColumn). The value of this column is in another column from db. I make it visible = false from server code.
When i export the grid in Excel (ExportOnlyData = True), i cannot see the value of the GridImageColumn
i want to show on excel the value of the column (db column) and not the icon column.

Thank you in advance for your time.

I Use:
VS 2008 (VB)
Telerik 2011.3.1305.35

Below is the client and server code.

<telerik:RadGrid ID="grdPPCOrders" runat="server" Height="300px" Skin="Windows7"
                    AllowMultiRowSelection="true">
                    <HeaderContextMenu CssClass="">
                    </HeaderContextMenu>
                    <MasterTableView DataKeyNames="ID">
                        <Columns>
                            <telerik:GridClientSelectColumn UniqueName="Selected" HeaderStyle-Width="30">
                                <HeaderStyle Width="30px"></HeaderStyle>
                            </telerik:GridClientSelectColumn>
                            <telerik:GridImageColumn UniqueName="CardTypeImage" HeaderStyle-Width="30" >
                                <HeaderStyle Width="30px"></HeaderStyle>
                            </telerik:GridImageColumn>
                            <telerik:GridImageColumn UniqueName="OrderStatusImage" HeaderStyle-Width="30">
                                <HeaderStyle Width="30px"></HeaderStyle>
                            </telerik:GridImageColumn>
                            <telerik:GridImageColumn UniqueName="HasCreditNoteImage" HeaderStyle-Width="30">
                                <HeaderStyle Width="30px"></HeaderStyle>
                            </telerik:GridImageColumn>
                            <telerik:GridBoundColumn FilterControlWidth="105px" DataField="ID" HeaderText="ID"
                                SortExpression="ID" UniqueName="ID2" AutoPostBackOnFilter="true" CurrentFilterFunction="Contains"
                                ShowFilterIcon="false" ItemStyle-Width="50" HeaderStyle-Width="50">
                                <HeaderStyle Width="50px"></HeaderStyle>
                                <ItemStyle Width="50px"></ItemStyle>
                            </telerik:GridBoundColumn>
                        </Columns>
                        <CommandItemSettings ShowExportToExcelButton="true" ShowAddNewRecordButton="false" />
                        <RowIndicatorColumn FilterControlAltText="Filter RowIndicator column">
                            <HeaderStyle Width="20px"></HeaderStyle>
                        </RowIndicatorColumn>
                        <ExpandCollapseColumn FilterControlAltText="Filter ExpandColumn column">
                            <HeaderStyle Width="20px"></HeaderStyle>
                        </ExpandCollapseColumn>
                        <EditFormSettings>
                            <EditColumn FilterControlAltText="Filter EditCommandColumn column">
                            </EditColumn>
                        </EditFormSettings>
                    </MasterTableView>
                    <ClientSettings AllowKeyboardNavigation="true" EnablePostBackOnRowClick="true" EnableRowHoverStyle="True">
                        <Selecting AllowRowSelect="True" EnableDragToSelectRows="False" />
                        <ClientEvents />
                        <Scrolling AllowScroll="true" UseStaticHeaders="True" SaveScrollPosition="True" />
                        <Resizing AllowColumnResize="True" AllowResizeToFit="True" EnableRealTimeResize="True" />
                    </ClientSettings>
                    <FilterMenu EnableImageSprites="False">
                    </FilterMenu>
                </telerik:RadGrid>


Server:
Protected Sub btnExportExcel_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnExportExcel.Click
    grdPPCOrders.ExportSettings.ExportOnlyData = True
    'grdPPCOrders.MasterTableView.Columns.Item(0).Visible = False
    'grdPPCOrders.MasterTableView.Columns.FindByDataField("CardType").Visible = True !ERROR Cannot find column bound to field
    'grdPPCOrders.Columns.FindByDataField("CardType").Visible = True !ERROR Cannot find column bound to field
    'grdPPCOrders.MasterTableView.Columns.Item(9).Visible = True
    grdPPCOrders.MasterTableView.ExportToExcel()
End Sub


Protected Sub grdPPCOrders_ColumnCreated(ByVal sender As Object, ByVal e As Telerik.Web.UI.GridColumnCreatedEventArgs) Handles grdPPCOrders.ColumnCreated
 
        Select Case e.Column.UniqueName
 
            Case "Notes", "ID", "SupplierID_CustomerID", "VesselID", "OrderStatus", "CardType", "HasCreditNote", "InvoiceDate", "Price", "NetProfit"
                Dim boundColumn As GridBoundColumn = CType(e.Column, GridBoundColumn)
                boundColumn.Visible = False
 
           End Select
 
    End Sub


Protected Sub grdPPCOrders_ItemDataBound(ByVal sender As Object, ByVal e As Telerik.Web.UI.GridItemEventArgs) Handles grdPPCOrders.ItemDataBound
        'Dim SelectedColumn(GridColumns.Count) As String
 
        If TypeOf e.Item Is GridHeaderItem Then
            Dim header As GridHeaderItem = DirectCast(e.Item, GridHeaderItem)
            'header("OrderStatus").Text = ""
            'header("HasCreditNote").Text = ""
 
        End If
 
        If TypeOf e.Item Is GridDataItem Then
            Dim dataItem As GridDataItem = CType(e.Item, GridDataItem)
 
            Dim CardTypeColumn As String = dataItem("CardType").Text
            If CardTypeColumn = "Virtual" Then
                CType(dataItem("CardTypeImage").Controls(0), Image).ImageUrl = "~/Images/CardVirtual.png"
            ElseIf CardTypeColumn = "Scratch" Then
                CType(dataItem("CardTypeImage").Controls(0), Image).ImageUrl = "~/Images/CardScratch.png"
            ElseIf CardTypeColumn = "VirtualOP" Then
                CType(dataItem("CardTypeImage").Controls(0), Image).ImageUrl = "~/Images/CardVirtualOP.png"
            ElseIf CardTypeColumn = "ScratchOP" Then
                CType(dataItem("CardTypeImage").Controls(0), Image).ImageUrl = "~/Images/CardScratchOP.png"
            End If
 
            Dim OrderStatusColumn As String = dataItem("OrderStatus").Text
            If OrderStatusColumn = "1" Then
                CType(dataItem("OrderStatusImage").Controls(0), Image).ImageUrl = "~/Images/OrderClosed.png"
            ElseIf OrderStatusColumn = "2" Then
                CType(dataItem("OrderStatusImage").Controls(0), Image).ImageUrl = "~/Images/OrderOpen.png"
            ElseIf OrderStatusColumn = "3" Then
                CType(dataItem("OrderStatusImage").Controls(0), Image).ImageUrl = "~/Images/OrderSuspended.png"
            ElseIf OrderStatusColumn = "4" Then
                CType(dataItem("OrderStatusImage").Controls(0), Image).ImageUrl = "~/Images/OrderClosedTr.png"
            ElseIf OrderStatusColumn = "5" Then
                CType(dataItem("OrderStatusImage").Controls(0), Image).ImageUrl = "~/Images/OrderOpenTr.png"
            ElseIf OrderStatusColumn = "6" Then
                CType(dataItem("OrderStatusImage").Controls(0), Image).ImageUrl = "~/Images/OrderSuspendedTr.png"
            End If
 
            Dim HasCreditNoteColumn As String = dataItem("HasCreditNote").Text
            If HasCreditNoteColumn = "1" Then
                CType(dataItem("HasCreditNoteImage").Controls(0), Image).ImageUrl = "~/Images/CreditNoteDiscount.png"
            ElseIf HasCreditNoteColumn = "2" Then
                CType(dataItem("HasCreditNoteImage").Controls(0), Image).ImageUrl = "~/Images/CreditNoteCards.png"
            Else
                dataItem("HasCreditNoteImage").Controls(0).Visible = False
            End If
 
 
            Dim TotalChargeColumn As String = dataItem("Charge").Text
            dataItem("Charge").Text = ConvertStringToDecimal(dataItem("Charge").Text, 2)
            dataItem("TotalCharge").Text = ConvertStringToDecimal(dataItem("TotalCharge").Text, 2)
            'dataItem("Price").Text = ConvertStringToDecimal(dataItem("Price").Text, 2)
 
            dataItem("Charge").HorizontalAlign = HorizontalAlign.Right
            dataItem("TotalCharge").HorizontalAlign = HorizontalAlign.Right
            'dataItem("Price").HorizontalAlign = HorizontalAlign.Right
            dataItem("Cards").HorizontalAlign = HorizontalAlign.Right
 
 
            Charge += dataItem("TotalCharge").Text
            Cards += dataItem("Cards").Text
 
            'If INMBData <> " " Then
            '    INMBValue += CDec(INMBData)
            'End If
 
            'Dim fieldValue As Int32 = Integer.Parse(dataItem("ID").Text)
            'TotalCharge = TotalCharge + TotalChargeField
 
        End If
 
        If (TypeOf e.Item Is GridFooterItem) Then
            Dim footerItem As GridFooterItem = CType(e.Item, GridFooterItem)
 
            footerItem("TotalCharge").Text = ConvertStringToDecimal(Charge.ToString, 2)
            footerItem("TotalCharge").HorizontalAlign = HorizontalAlign.Right
            footerItem("Cards").Text = ConvertStringToDecimal(Cards, 0)
            footerItem("Cards").HorizontalAlign = HorizontalAlign.Right
 
            'footerItem("INMB~Data (1.35$ / MIN)").Text = INMBValue.ToString()
            footerItem("Vessel").Controls.Add(New LiteralControl("<span style='color: Black; font-weight: bold;'>Totals:</span> "))
        End If
 
 
    End Sub



Technology
Top achievements
Rank 1
 answered on 29 Nov 2012
3 answers
71 views
Hi guys

I am staring at this but cannot see anything wrong. But it does not trigger validation when there is no text entered in the editor on Update. What am I missing?

Thanks

Clive
PS Q2 2010 asp.net 4 .   I am not using ajax manager on this page

<telerik:GridHTMLEditorColumn DataField="BodyText" HeaderText="BodyText" SortExpression="BodyText" UniqueName="BodyText" ColumnEditorID="MyColumnEditor1">
 </telerik:GridHTMLEditorColumn>
 
Protected Sub RadGrid1_ItemCreated(ByVal sender As Object, ByVal e As Telerik.Web.UI.GridItemEventArgs)
        If (TypeOf e.Item Is GridEditableItem AndAlso e.Item.IsInEditMode) Then
            Dim item As GridEditableItem = CType(e.Item, GridEditableItem)
            Dim editor As GridTextBoxColumnEditor = CType(item.EditManager.GetColumnEditor("BodyText"), GridTextBoxColumnEditor)
            Dim cell As TableCell = CType(editor.TextBoxControl.Parent, TableCell)
            Dim validator As RequiredFieldValidator = New RequiredFieldValidator
            editor.TextBoxControl.ID = "MyColumnEditor1"
            validator.ControlToValidate = editor.TextBoxControl.ID
            validator.ErrorMessage = "Please enter some text!"
            cell.Controls.Add(validator)
        End If
    End Sub

Angel Petrov
Telerik team
 answered on 29 Nov 2012
1 answer
62 views
I've got a bound column that may contain null values. If I try to use filtering on it such as "contains" or "equal", I'm getting a javascript error "Object reference not set to an instance of the object". I believe the generated logic should check for null before applying the "contains" filter. Am I doing something wrong here or is it a bug? In some posts I found that EnableLinqExpressions="false"  would fix something like that. However, when I try to do that I'm getting 

Server Error in '/' Application.

Cannot interpret token '?' at position 12

The grid is bound to a list of objects and is defined as follows 
<telerik:RadGrid ID="EmployeesRadGrid" runat="server" AutoGenerateColumns="false"
                       AllowPaging="true" OnNeedDataSource="EmployeesRadGrid_NeedDataSource" EnableLinqExpressions="false"
                       oninit="EmployeesRadGrid_Init" onitemcommand="EmployeesRadGrid_ItemCommand">
                       <GroupingSettings CaseSensitive="False" />
                       <ExportSettings HideStructureColumns="true" FileName="Employees" Excel-Format="Biff"
                           OpenInNewWindow="false" Excel-FileExtension="xls" IgnorePaging="true" ExportOnlyData="false" />
                       <MasterTableView EditMode="PopUp" AllowFilteringByColumn="true" AllowSorting="true"
                           CommandItemDisplay="Top">
                           <CommandItemSettings ShowExportToExcelButton="true" ExportToExcelText="Export to Excel"
                               ShowAddNewRecordButton="false" />
                           <Columns>
                               <telerik:GridHyperLinkColumn DataNavigateUrlFields="PersonnelNo" UniqueName="Edit"
                                   AllowFiltering="false" DataNavigateUrlFormatString="EditEmployee.aspx?PersonnelNo={0}"
                                   Text="Edit" >
                               </telerik:GridHyperLinkColumn>
                               <telerik:GridCalculatedColumn HeaderTooltip="*= override" Expression="IsOverriden?  Convert.ToChar(42): Convert.ToChar(32)"
                                   AllowFiltering="false">
                               </telerik:GridCalculatedColumn>
                               <telerik:GridBoundColumn DataField="RacfID" HeaderText="RACF ID" CurrentFilterFunction="Contains"
                                   FilterControlWidth="4em" AutoPostBackOnFilter="true" ShowFilterIcon="true" >
                               </telerik:GridBoundColumn>
                               <telerik:GridBoundColumn DataField="FullName" HeaderText="Name" CurrentFilterFunction="Contains"
                                   AutoPostBackOnFilter="true" >
                               </telerik:GridBoundColumn>
                               <telerik:GridBoundColumn DataField="PositionName" HeaderText="Job Title" CurrentFilterFunction="Contains"
                                   FilterControlToolTip="Enter search value and press Tab or Enter" FilterControlWidth="9em"
                                   AutoPostBackOnFilter="true" >
                               </telerik:GridBoundColumn>
                               <telerik:GridBoundColumn DataField="PersonnelAreaDescription" HeaderText="Work Location"
                                   CurrentFilterFunction="Contains" FilterControlWidth="11em" AutoPostBackOnFilter="true"
                                   ShowFilterIcon="false">
                               </telerik:GridBoundColumn>
                               <telerik:GridBoundColumn DataField="OrgUnit" HeaderText="Org Unit" CurrentFilterFunction="Contains"
                                   FilterControlWidth="6em" AutoPostBackOnFilter="true">
                               </telerik:GridBoundColumn>
                               <telerik:GridBoundColumn DataField="BusinessSalesUnit" HeaderText="Sls-Bus Unit" FilterDelay="10000"
                                   FilterControlWidth="4em"  AutoPostBackOnFilter="true" >
                               </telerik:GridBoundColumn>
                               <telerik:GridBoundColumn DataField="DeptRegion" HeaderText="Dept-Region" CurrentFilterFunction="Contains"
                                   FilterControlWidth="4em" AutoPostBackOnFilter="true" >
                               </telerik:GridBoundColumn>
                               <telerik:GridBoundColumn DataField="CostCenterDisplay" HeaderText="Cost center" CurrentFilterFunction="Contains"
                                   FilterControlWidth="4em" AutoPostBackOnFilter="true" >
                               </telerik:GridBoundColumn>
                           </Columns>
                       </MasterTableView>
                   </telerik:RadGrid>


Thanks,
Alex

Kostadin
Telerik team
 answered on 29 Nov 2012
4 answers
94 views
Hi,

i am using the grid and have written a function that allow me to set all the viable rows to be edited using the inline edit method. 

the grid is initially populated with 1000 rows by being bound to a data table, the grid has paging set at 25 lines per page and the user can edit all 25 items in one go,  when they click update my code loops through the viable items and adds them to a new data table and this is returned to an update function. 

the data table that is sent back only contain 25 rows but seems to be over a meg in size and this really kill the performance of the page when using it over a Normal ADSL connection.

can anyone tell me why the data table is so big as the data contained with in it should be a few K and i do not seem to have the same issue when the data is retrieved on load of the page.



Pavlina
Telerik team
 answered on 29 Nov 2012
Narrow your results
Selected tags
Tags
+? more
Top users last month
Jay
Top achievements
Rank 3
Iron
Iron
Iron
Benjamin
Top achievements
Rank 3
Bronze
Iron
Veteran
Radek
Top achievements
Rank 2
Iron
Iron
Iron
Bohdan
Top achievements
Rank 2
Iron
Iron
Richard
Top achievements
Rank 4
Bronze
Bronze
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Jay
Top achievements
Rank 3
Iron
Iron
Iron
Benjamin
Top achievements
Rank 3
Bronze
Iron
Veteran
Radek
Top achievements
Rank 2
Iron
Iron
Iron
Bohdan
Top achievements
Rank 2
Iron
Iron
Richard
Top achievements
Rank 4
Bronze
Bronze
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?