Telerik Forums
UI for ASP.NET AJAX Forum
1 answer
77 views
I can load a RadGrid in the main page using get_masterTableView().  However, If I have the grid in an ASCX page, what do I need to do to load that grid from the main ASPX page?  I can get a reference to the grid:
var myGrid = document.getElementById('<%= ((RadGrid)myControl.FindControl("RadGrid1")).ClientID %>')
but get_masterTableView() is not valid for myGrid.
Marin
Telerik team
 answered on 22 Aug 2012
3 answers
182 views
I have been adding validation to a RadGrid, whenever i try to add any Validation groups it causes the RequiredFieldValidator to not work at all

Is there any work around for this? I would like to have a summary of errors listed

<telerik:RadGrid ID="RadGrid2" runat="server" Width="100%"
                    AllowAutomaticInserts="True"
                    AllowAutomaticUpdates="True"
                    AllowPaging="True"
                    AllowMultiRowEdit="false"
                    AllowMultiRowSelection="false"
                    AutoGenerateColumns="False"
                    DataSourceID="SqlDataSource2"
                    EnableLinqExpressions="false"
                    GridLines="None"
                    OnItemCreated="RadGrid2_ItemCreated"
                    OnItemDataBound="RadGrid2_ItemDataBound"
                    OnItemUpdated="RadGrid2_ItemUpdated"
                    OnItemInserted="RadGrid2_ItemInserted"
                    OnDataBound="RadGrid2_DataBound"
                    OnItemCommand="RadGrid2_ItemCommand"
                    OnPreRender="RadGrid2_PreRender">
                    <PagerStyle Mode="NextPrevAndNumeric" />
                    <MasterTableView Width="100%" CommandItemDisplay="Bottom" EditMode="InPlace"
                        DataSourceID="SqlDataSource2" HorizontalAlign="NotSet" AutoGenerateColumns="false">
                        <Columns>
                            <telerik:GridBoundColumn DataField="ProductTypeId" HeaderText="ProductTypeId" SortExpression="ProductTypeId" UniqueName="ProductTypeId" Visible="false">
                            </telerik:GridBoundColumn>
 
                            <telerik:GridBoundColumn DataField="ProductAttributeDefKeyOri" HeaderText="ProductAttributeDefKeyOri" SortExpression="ProductAttributeDefKeyOri" UniqueName="ProductAttributeDefKeyOri" Visible="false">
                            </telerik:GridBoundColumn>
                             
                            <telerik:GridDropDownColumn ListTextField="Name" ListValueField="ProductAttributeDefKey" DataSourceID="SqlDataSource3" HeaderText="Attribute" DataField="ProductAttributeDefKey" UniqueName="ProductAttributeDefKey" DropDownControlType="DropDownList" EnableEmptyListItem="true" EmptyListItemText="Select an attribute..." EmptyListItemValue="">
                            </telerik:GridDropDownColumn>
 
                            <telerik:GridTemplateColumn DefaultInsertValue="1" DataField="SortOrder" HeaderText="Sort Order" SortExpression="SortOrder" UniqueName="SortOrder"  ForceExtractValue="Always" >
                                <EditItemTemplate>
                                    <telerik:RadNumericTextBox runat="server" ID="tbSortOrder" DbValue='<%# Bind("SortOrder") %>' ShowSpinButtons="true" SpinDownCssClass="" SpinUpCssClass="" Width="50px" MinValue="1" MaxValue="999" NumberFormat-DecimalDigits="0" CssClass="textbox_increment">
                                    </telerik:RadNumericTextBox>
                                    <asp:RequiredFieldValidator runat="server" ControlToValidate="tbSortOrder" ErrorMessage="*" ValidationGroup="grid2"></asp:RequiredFieldValidator>
                                </EditItemTemplate>
                                <ItemTemplate>
                                    <%# Eval("SortOrder")%>
                                </ItemTemplate>
                                <ItemStyle CssClass="MyImageButton" />
                            </telerik:GridTemplateColumn>
 
                            <telerik:GridCheckBoxColumn DataField="Enabled" HeaderText="Enabled" SortExpression="Enabled" UniqueName="Enabled" DefaultInsertValue="Checked"  >
                            </telerik:GridCheckBoxColumn>
 
                            <telerik:GridCheckBoxColumn DataField="Required" HeaderText="Required" SortExpression="Required" UniqueName="Required" DefaultInsertValue="1">
                            </telerik:GridCheckBoxColumn>
 
                            <telerik:GridEditCommandColumn ButtonType="ImageButton" UniqueName="EditCommandColumn">
                                <ItemStyle CssClass="MyImageButton" />
                            </telerik:GridEditCommandColumn>
                        </Columns>
                        <EditFormSettings ColumnNumber="2" CaptionFormatString="Edit Attribute" InsertCaption="Add Attribute">
                            <FormTableItemStyle Wrap="true"></FormTableItemStyle>
                            <FormCaptionStyle CssClass="EditFormHeader"></FormCaptionStyle>
                            <FormMainTableStyle GridLines="None" CellSpacing="0" CellPadding="0" BackColor="White" Width="100%" />
                            <FormTableStyle CellSpacing="0" CellPadding="1" BackColor="White" />
                            <FormTableAlternatingItemStyle Wrap="False"></FormTableAlternatingItemStyle>
                            <PopUpSettings Modal="true" />
                            <EditColumn ButtonType="ImageButton" InsertText="Add Attribute" UpdateText="Update Attribute" UniqueName="EditCommandColumn1" CancelText="Cancel Edit"></EditColumn>
                            <FormTableButtonRowStyle HorizontalAlign="Right" CssClass="EditFormButtonRow"></FormTableButtonRowStyle>
                        </EditFormSettings>
                        <CommandItemSettings AddNewRecordText="Add Attribute" />
                    </MasterTableView>
                </telerik:RadGrid>

protected void RadGrid2_ItemCreated(object sender, Telerik.Web.UI.GridItemEventArgs e)
        {
            if (e.Item is GridEditableItem && e.Item.IsInEditMode)
            {
                //attribute validation
                GridEditableItem item = e.Item as GridEditableItem;
                DropDownList dropDownList1 = item["ProductAttributeDefKey"].Controls[0] as DropDownList;
                GridDropDownColumnEditor editor = (GridDropDownColumnEditor)item.EditManager.GetColumnEditor("ProductAttributeDefKey");
                TableCell cell = (TableCell)editor.ContainerControl;
 
                RequiredFieldValidator validator = new RequiredFieldValidator();
                validator.ControlToValidate = dropDownList1.ID;
                validator.ErrorMessage = "*";
                validator.ValidationGroup = "grid2";
                cell.Controls.Add(validator);
            }
             
            if (e.Item is GridEditableItem && e.Item.IsInEditMode)
            {
                if (e.Item.OwnerTableView.IsItemInserted)
                {
                    //set required and enabled default values for inserting
                    GridEditableItem edititem = (GridEditableItem)e.Item;
                    CheckBox chkbx = (CheckBox)edititem["Enabled"].Controls[0];
                    chkbx.Checked = true;
                    chkbx = (CheckBox)edititem["Required"].Controls[0];
                    chkbx.Checked = true;
                }
            }
        }

Marin
Telerik team
 answered on 22 Aug 2012
1 answer
88 views
Hi, I was searching for the telerik radtextbox in my asp.net project and I can't find the control. Am I able to use this control in my web project? If so, could you tell me how I would get that dll into my project so I can start using the control?

Thanks,
Ben
Shinu
Top achievements
Rank 2
 answered on 22 Aug 2012
3 answers
147 views
I had several issues when I converted my classic radcontrols Q3 2008 to asp.net ajax Q1 2012. I had updated as well the framework from .Net 2.0 to .Net 4.0 and using Visual Studio 2010 from VS2k5. Now only button works well with RadAjaxManager. All my asp Dropdown, Checkbox, Radiobutton etc dont fire postback anymore and no longer works with RadAjaxManager. Any reason why this happen? Any workaround?
Cat Cheshire
Top achievements
Rank 1
 answered on 22 Aug 2012
1 answer
108 views
When I drag a file over the upload text, it will show a section with text "Drop files here". Is there a way to customize the section style such as backgroud-color, padding-top, padding-left?
Princy
Top achievements
Rank 2
 answered on 22 Aug 2012
4 answers
490 views
Hi,

I am using asp.net 2.0.

Protected Sub RadGrid1_ItemCommand(ByVal source As Object, ByVal e As Telerik.Web.UI.GridCommandEventArgs) Handles RadGrid1.ItemCommand
        If e.CommandName = "RowClick" Then
            Dim item As GridDataItem = e.Item
            selUserid = item("UserId").Text
            TxtName.Text = item("Name").Text
            TxtUserName.Text = item("UserName").Text
            TxtEmail.Text = item("Email").Text
            TxtPassword.Text = item("Password").Text 
            TxtPhone.Text = item("UserPhone").Text
            cmbCity.Text = item("PosId").Text
        End If
    End Sub


The password textbox is in password mode, but by clicking on grid all the textboxes are filled with values except password textbox.

Can any body help me out.

Thanks in advance
Shinu
Top achievements
Rank 2
 answered on 22 Aug 2012
1 answer
191 views
I'm binding a RadGrid to a BindingList, when I edit a Template column with a dropDown I'm trying  it to keep the previously selected value

here is a sample of my code:

<telerik:GridTemplateColumn HeaderText="Contributor" UniqueName="Contributor" DataField="Contrib">
    <EditItemTemplate>
        <asp:DropDownList ID="ddContributor" runat="server" DataSourceID="ldsContibutors"
        DataTextField="ContributorName" DataValueField="ContributorID" AppendDataBoundItems="True"
        SelectedValue='<%# Eval("Contrib.ContributorID") %>'>
            <asp:ListItem>Select a value</asp:ListItem>
        </asp:DropDownList>
    </EditItemTemplate>
    <ItemTemplate>
        <%# Eval("Contrib.ContributorName") %>
    </ItemTemplate>


eval works fine but bind throws an exception: DataBinding: 'Telerik.Web.UI.GridInsertionObject' does not contain a property with the name 'Contrib'.


I also tried in cs but I cannot find the value in the item["Contributor"].Text 
then I tried witha a label in the Item template,  ((Label)item["Contributor"].findControl("labelID")).Text but it's always ""
any help will be apreciated thanks!
Princy
Top achievements
Rank 2
 answered on 22 Aug 2012
1 answer
167 views
I have this code in the Pre Render event in one of my RadGrids.............



 For Each item As GridDataItem In Radgrid_AddRemoveProvider.MasterTableView.Items
            Dim lblPID As Label = DirectCast(item.FindControl("lblPID"), Label)

            Dim btnAddProvider As LinkButton = DirectCast(item.FindControl("btnAddProvider"), LinkButton)
            Dim btnRemoveProvider As LinkButton = DirectCast(item.FindControl("btnRemoveProvider"), LinkButton)
            Dim lblFullName As Label = DirectCast(item.FindControl("lblFullName"), Label)
            Dim btnFullName As LinkButton = DirectCast(item.FindControl("btnFullName"), LinkButton)
            '  Dim lblContactType As Label = DirectCast(item.FindControl("lblContactType"), Label)
            ' Dim ddPreferredContact As DropDownList = DirectCast(item.FindControl("ddPreferredContact"), DropDownList)

            If lblPID.Text = Nothing Then
                btnAddProvider.Visible = True
                'ddPreferredContact.Visible = True
                'lblContactType.Visible = False
                btnRemoveProvider.Visible = False
                lblFullName.Visible = True
                btnFullName.Visible = False
            ElseIf lblPID.Text <> Nothing Then
                btnAddProvider.Visible = False
                'ddPreferredContact.Visible = False
                'lblContactType.Visible = True
                btnRemoveProvider.Visible = True
                lblFullName.Visible = False
                btnFullName.Visible = True
            End If

Next



However it loops through this code 100 times looping through each item in my RadGrid.  The problem is that it goes through this loop every time I perform any sort of event on the page.  Is there anyway I can tell it to stop looping through this code when i am not working with this RadGrid on the page.  I tried putting the code in the ItemCreated event, but it does the same thing. Overall I believe this is effecting the performance and speed of my page. 
Shinu
Top achievements
Rank 2
 answered on 22 Aug 2012
1 answer
81 views
Hi,

I am using radgrid and in itemtempalte I have a dropdownlist and a label control. OnItemDatabound event I am passing the ids of dropdownlist and a label control to a javascript function. The functions finds the client ids of the dropdownlist and a label control but when I use document.getElementbyId for label control it gives me null.

Any help would be really appreciated.

Thanks



function OnSelectedIndexChange(ddlTopic, lblTopic) {
 
       alert(ddlTopic);
       alert(lblTopic);
       var ddl = document.getElementById(ddlTopic);
       var lbl = document.getElementById(lblTopic); // The problem occurs here 
       alert(lbl);  
       ddl.style.display = "none";       
        
 
   }
 
 
 
 
<telerik:RadGrid ID="gvTopics" runat="server" Font-Names="Verdana" Font-Size="XX-Small"
                   Skin="Outlook" EnableEmbeddedSkins="true" GridLines="Vertical" AllowSorting="true"
                   AllowPaging="true" Width="99%" CellPadding="2" AutoGenerateColumns="False">
                   <MasterTableView CommandItemDisplay="Top">
                       <CommandItemSettings ShowAddNewRecordButton="false" />
                       <Columns>
<telerik:GridTemplateColumn SortExpression="Topic" HeaderText="Topic">
                               <ItemTemplate>
                                   <asp:LinkButton ID="lnkTopic" Text='<%# Bind("Topic") %>' runat="server"></asp:LinkButton>
                                   <telerik:RadToolTip ID="rttpTopics" Width="350" Height="100" HideEvent="ManualClose"
                                       TargetControlID="lnkTopic" RelativeTo="Element" Skin="Windows7" Position="TopRight"
                                       ManualClose="true" ShowEvent="OnClick" runat="server">
                                       <table width="100%">
                                           <tr>
                                               <td width="40%">
                                                   select topic :
                                               </td>
                                               <td>
                                                   <asp:DropDownList ID="ddlTopic" runat="server" Font-Names="Verdana" Font-Size="XX-Small"
                                                       ValidationGroup="selecttopic" AutoPostBack="false" />
                                                    <asp:RequiredFieldValidator ID="rfvTopic" runat="server" ErrorMessage="## please select a topic"
                                                       InitialValue="- please select -" ControlToValidate="ddlTopic" Font-Bold="True"
                                                       Font-Names="Arial" Font-Size="X-Small" SetFocusOnError="True" ValidationGroup="selecttopic" />
                                                   <telerik:RadTextBox ID="rtbTopicName" EmptyMessage="please enter topic name"
                                                       runat="server">
                                                   </telerik:RadTextBox>
                                                   <asp:Label ID="lblTopicName" Text="TopicName" Visible="false" runat="server"></asp:Label>
                                               </td>
                                           </tr>
                                           <tr>
                                               <td>
                                               </td>
                                               <td>
                                                   <asp:Button ID="btnSaveTopic" CommandArgument='<%# Container.DataItem("id")%>' ValidationGroup="selecttopic"
                                                       CausesValidation="true" OnClick="btnSaveTopic_Click" Text="Save" runat="server" />
                                               </td>
                                           </tr>
                                       </table>
                                   </telerik:RadToolTip>
                               </ItemTemplate>
                           </telerik:GridTemplateColumn>
</Columns>
                       <NoRecordsTemplate>
                           <asp:Label ID="Label5" runat="server" Text="no topics found"></asp:Label>
                       </NoRecordsTemplate>
                   </MasterTableView>
               </telerik:RadGrid>
 
 
 
Protected Sub gvTopics_OnItemDataBound(ByVal sender As Object, ByVal e As GridItemEventArgs) Handles gvTopics.ItemDataBound
 
       If TypeOf (e.Item) Is GridDataItem Then
 
           Dim ddlTopic As DropDownList = e.Item.FindControl("ddlTopic")
           Dim lblTopicName As Label = e.Item.FindControl("lblTopicName")
           ddlTopic.Attributes.Add("onChange", "return OnSelectedIndexChange('" & ddlTopic.ClientID & "','" & lblTopicName.ClientID & "');")
 
   End Sub
Shinu
Top achievements
Rank 2
 answered on 22 Aug 2012
2 answers
84 views
Hi,

I need a help regarding the Read menu with WCF and radgrid. 

I have a red grid with template column. In Template column there is a RedMenu. That rad menu items will be desided (when expand get from WCF service) . I followed the link below. It worked well.  

http://www.telerik.com/help/aspnet-ajax/menu-items-wcf-service.html.

But in my case I need to pass data from the row in DataGrid to WCF service. For example will assume grid containes Order details and column with "Order Number". I need to pass the "Order Number" to the WCF method as done in above sample.

sample has done this using js method as follows.

function OnClientItemPopulatingHandler(sender, e) 
    {        
        var context = e.get_context();
        //using jQuery to get the checked item and pass it to the server        
        context["ProductSuite"] = $telerik.$("input[name='rblSuites']:checked").val();
    }

I need to do this as follows

function OnClientItemPopulatingHandler(sender, e) 
    {        
        var context = e.get_context();
        //using jQuery to get the checked item and pass it to the server        
        context["OrderNumber"] = GET THE ORDER NUMBER FROM ROW BELONGS TO THE RADMENU.
    }

can anybody help me to resolve this ?

Thank you
Dinesh
Top achievements
Rank 1
 answered on 22 Aug 2012
Narrow your results
Selected tags
Tags
+? more
Top users last month
Boardy
Top achievements
Rank 2
Veteran
Iron
Benjamin
Top achievements
Rank 3
Bronze
Iron
Veteran
ivory
Top achievements
Rank 1
Iron
Iron
Rob
Top achievements
Rank 3
Bronze
Bronze
Iron
ClausDC
Top achievements
Rank 2
Iron
Iron
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Boardy
Top achievements
Rank 2
Veteran
Iron
Benjamin
Top achievements
Rank 3
Bronze
Iron
Veteran
ivory
Top achievements
Rank 1
Iron
Iron
Rob
Top achievements
Rank 3
Bronze
Bronze
Iron
ClausDC
Top achievements
Rank 2
Iron
Iron
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?