Telerik Forums
UI for ASP.NET AJAX Forum
2 answers
395 views

I have some code I'm troubleshooting from our offshore team.  We have a datagrid that we want to enable paging on, the problem is that the CurrentPageIndex of the RadGrid is always 0.  We aren't using a DataSource property but retrieving our data via a service layer in the code-behind that calls a stored proc that uses OFFSET and FETCH to return the subset of rows based on the page index and page size.

Here's the ASPX code for the RadGrid:

<telerik:RadGrid ID="EnrollmentPeriodCompanyElectionsGrid" runat="server" AllowSorting="true" AutoGenerateColumns="false" PageSize="20" AllowPaging="True" AllowCustomPaging="true" OnPageIndexChanged="EnrollmentPeriodCompanyElectionsGrid_PageIndexChanged"
    OnPageSizeChanged="EnrollmentPeriodCompanyElectionsGrid_PageSizeChanged" OnNeedDataSource="EnrollmentPeriodCompanyElectionsGrid_NeedDataSource" OnItemDataBound="EnrollmentPeriodCompanyElectionsGrid_ItemDataBound" EnableViewState="true">
 
    <MasterTableView NoMasterRecordsText="Nothing was found for this election period">
        <Columns>
            <telerik:GridBoundColumn DataField="HrpClientID" HeaderText="ID" SortExpression="HrpClientID" />
            <telerik:GridHyperLinkColumn HeaderText="COMPANY" UniqueName="Company" SortExpression="CompanyName" DataTextField="CompanyName" DataNavigateUrlFields="CompanyID,BenefitEnrollmentPeriodID" DataNavigateUrlFormatString="~/Admin/Companies/Company.aspx?companyID={0}&page=Exhibits&periodID={1}"
                HeaderStyle-Width="300px" />
            <telerik:GridBoundColumn DataField="CompanyType" HeaderText="TYPE" SortExpression="CompanyType" />
            <telerik:GridBoundColumn DataField="HRP" HeaderText="HRP" SortExpression="HRP" />
            <telerik:GridBoundColumn DataField="HRC" HeaderText="HRC" SortExpression="HRC" />
            <telerik:GridBoundColumn DataField="EnrollmentStatus" SortExpression="EnrollmentStatus" HeaderText="STATUS" />
        </Columns>
    </MasterTableView>
</telerik:RadGrid>

Here's the NeedDataSource method:

protected void EnrollmentPeriodCompanyElectionsGrid_NeedDataSource(object sender, GridNeedDataSourceEventArgs e)
        {
            try
            {
                var enrollmentId = Request.QueryString["PeriodID"] != null ? int.Parse(Request.QueryString["PeriodID"]) : 0;
                {
                    RadGrid enrollmentPeriodCompanyElectionsGrid = (RadGrid)sender;
 
                    int currentPageIndex = EnrollmentPeriodCompanyElectionsGrid.CurrentPageIndex;
                    var dataSource = GetBenefitEnrollmentCompanies(enrollmentId, currentPageIndex, pageSize);
 
                    enrollmentPeriodCompanyElectionsGrid.DataSource = dataSource.BenefitEnrollmentCompanyDetail;
 
                    // set this only once.
                    if (enrollmentPeriodCompanyElectionsGrid.VirtualItemCount == 0)
                        enrollmentPeriodCompanyElectionsGrid.VirtualItemCount = dataSource.TotalRecordsCount;
                }
 
            }
            catch (Exception ex)
            {
                ErrorHandler.HandleError<Exception>(ex, new { UserID = CurrentUser.UserID, CompanyID = CurrentCompany.CompanyID, ViewingUserID = CurrentUser.UserID, PageIndex = 1, PageSize = pageSize });
            }
        }

and PageIndexChanged:

protected void EnrollmentPeriodCompanyElectionsGrid_PageIndexChanged(object sender, GridPageChangedEventArgs e)
    {
        try
        {
            // reset this property to new page after.
            EnrollmentPeriodCompanyElectionsGrid.CurrentPageIndex = e.NewPageIndex + 1;
        }
        catch (Exception ex)
        {
            ErrorHandler.HandleError<Exception>(ex, new { UserID = CurrentUser.UserID, CompanyID = CurrentCompany.CompanyID, ViewingUserID = CurrentUser.UserID, PageIndex = e.NewPageIndex, PageSize = pageSize });
        }
    }

However, no matter what the CurrentPageIndex is 0.  I've verified by manually changing the CurrentPageIndex in Visual Studio that, when set, paging works correctly, it just is always being set to 0.  I've tried everything, but I can't get the paging to recognize that I'm selecting a new page.

Kostadin
Telerik team
 answered on 11 Jul 2016
4 answers
64 views

I have a DDT binding server side to Id & Name, I also have checkboxes

rdtLocation.DataSource = locations;
rdtLocation.DataTextField = "Name";
rdtLocation.DataFieldID = "Id";
rdtLocation.DataValueField = "Id";
rdtLocation.DataFieldParentID = "ParentId";
rdtLocation.DataSource = locations;
rdtLocation.DataBind();

With one selected item when I look at the selectedValue I get a comma separated list containing 2 instances of the id. ie - "2,2"

See attached screen shot.

Why is this and what is the fix.

Andy

Eyup
Telerik team
 answered on 11 Jul 2016
1 answer
177 views

Hi there,

I need to show next and prev button above rad grid so that when my site is open on mobile view, user can navigate to rest of the columns. Every column is given fixed width. But the issue I am facing that I must have to freeze at least one column.

Current code:

<MasterTableView DataKeyNames="UserID" HeaderStyle-Width="100px" TableLayout="Auto" CommandItemDisplay="TopAndBottom" CommandItemSettings-ShowAddNewRecordButton="false" CommandItemSettings-ShowRefreshButton="false" CommandItemSettings-NextFrozenColumnText="Next Column" CommandItemSettings-PrevFrozenColumnText="Previous Column">

 <ClientSettings>
         <Scrolling AllowScroll="true" UseStaticHeaders="true" FrozenColumnsCount="1" EnableNextPrevFrozenColumns="true" />
 </ClientSettings>

When I set FrozenColumnsCount="0", next and prev button stop working.

Kindly provide the solution so that no column would get freezed.

 

Viktor Tachev
Telerik team
 answered on 11 Jul 2016
1 answer
392 views

I have a radgrid which is batch edit mode. How can I get one column value and set Max value to another Column in grid.

Thank You.

Eyup
Telerik team
 answered on 11 Jul 2016
1 answer
107 views

Hello, 

As far as I know the RadMap is missing a Scale control.

Researching what to do i came across the following example to manually add one: http://dojo.telerik.com/ogAke

I have implemented this but its not satisfying, in bigger zooms there is a bug and the numbers go smaller. (i believe the javascript var is overflowing)

Anyhow, do you have any suggestions about which alternative could i follow to implement a nice scale? Is Telerik planning on adding the scale?

Thank you!

 

 

Ianko
Telerik team
 answered on 11 Jul 2016
4 answers
200 views
Hi there,

I have a radwindow that performs a search on data and displays a list within a repeater of options the user may select.
What I need to do is collect the repeater object and send back to the parent. 

I looked at some of your examples using javascript, the problem is using javascript to grab the data within the repeater is quite ugly.

Is there a way I can pass the code back via code behind?
So in my repeater I have a button "select" when user clicks the "select" button the radwindow closes and
the parent receives the selection. 

My repeater code

​<asp:Repeater ID="rptStores" runat="server" OnItemDataBound="rptStores_ItemDataBound">
<HeaderTemplate>
<table>
<tr style="color:#ffd700; font-weight:bold;">
<td>Store Name</td>
<td>City</td>
<td>Street</td>
<td>Distance(Mi.)</td>
</tr>
</HeaderTemplate>
<ItemTemplate>
<tr style="color:#fff;" onmouseover="this.style.backgroundColor='blue'" onmouseout="this.style.backgroundColor=''" class="<%# If(Container.ItemIndex Mod 2 = 0, "TRNormal", "TRAlt") %>">
<td style="padding: 4px;">
<asp:Label ID="lblDBAName" runat="server" Text='<%# Eval("DBAName") %>' />
<asp:HiddenField ID="hfRowID" runat="server" Value='<%# Eval("id") %>' />
</td>
<td style="padding: 4px;">
<asp:Label ID="lblCity" runat="server" Text='<%# Eval("State") +"-"+ Eval("City")%>' />
<asp:HiddenField ID="hfState" runat="server" Value='<%# Eval("state") %>' />
</td>
<td style="padding: 4px;">
<asp:Label ID="lblStreet" runat="server" Text='<%# Eval("Street1") %>' />
<asp:HiddenField ID="hfPhone" runat="server" Value='<%# Eval("phone") %>' />
</td>
<td style="padding: 4px;">
<asp:Label ID="lblDistance" runat="server" Text='<%# Eval("distance") %>' />
</td>
<td>
<telerik:RadButton runat="server" Text="Select" ID="storeSelection2" CommandName="Process" Skin="Black" OnClientClicked="returnToParent"></telerik:RadButton>
</td>
</tr>
</ItemTemplate>
<FooterTemplate>
<tr>
<td>
<asp:Label ID="lblEmptyData" Text="No Data To Display" runat="server" Visible="false"></asp:Label>
</td>
</tr>
</table>
</FooterTemplate>
</asp:Repeater>


my vb

Protected Sub rptStores_ItemCommand(ByVal source As Object, ByVal e As System.Web.UI.WebControls.RepeaterCommandEventArgs) Handles rptStores.ItemCommand

Dim dbaName As Label
dbaName = CType(e.Item.FindControl("lblDBAName"), Label)

Dim city As Label
city = CType(e.Item.FindControl("lblCity"), Label)

Dim state As HiddenField
state = CType(e.Item.FindControl("hfState"), HiddenField)

Dim phone As HiddenField
phone = CType(e.Item.FindControl("hfPhone"), HiddenField)

Dim street1 As Label
street1 = CType(e.Item.FindControl("lblStreet"), Label)

Dim selectedID As HiddenField
selectedID = CType(e.Item.FindControl("hfRowID"), HiddenField)

ProcessButton(dbaName.Text, street1.Text, city.Text, state.Value, phone.Value, selectedID.Value)

End Sub

ProcessButton is called AFTER a return to parent javascript call.

Is this an option or do i really need to send object via javascript back to parent and then push into code behind.

Julius
Top achievements
Rank 1
 answered on 10 Jul 2016
10 answers
401 views
Hi-

I'm using a RadAjaxManager with some RadNumericTextBoxes and an asp:Button.  The button OnClick and the OnTextChanged are using the RadAjaxManager to update some Labels.

This works fine until I change the value in the RadNumericTextBox and then try to click on the button directly.  In this case, it seems to lose the click.

You can reproduce this by:
1) changing the values using the spinner in each of the two rad input boxes to verify that the "lblTotal" label changes.
2) click "OK" to show that the date is updated
3) change a value in one of the RadNumericTextBoxes using the keyboard and then clicking on the OK button directly.

You'll see that the date doesn't update---it's like an event is being lost somewhere.  This happens in both Firefox and IE8 on build 2009.02.0826.35.

Any idea what might cause that?

Thanks!

-Mike


<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="RadAjaxProblem.aspx.cs" 
    Inherits="Ajax.RadAjaxProblem" %> 
 
<%@ Register TagPrefix="telerik" Namespace="Telerik.Web.UI" Assembly="Telerik.Web.UI" %> 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml"
<head runat="server"
    <title>Test Ajax</title> 
</head> 
<body> 
 <form id="form1" runat="server"
    <asp:ScriptManager ID="scriptManagerProxy1" runat="server"
    </asp:ScriptManager> 
    <telerik:RadAjaxManager ID="RadAjaxManager1" runat="server" OnAjaxRequest="RadAjaxManager1_AjaxRequest"
        <AjaxSettings> 
            <telerik:AjaxSetting AjaxControlID="radNumber1"
                <UpdatedControls> 
                    <telerik:AjaxUpdatedControl ControlID="lblTotal" UpdatePanelRenderMode="Inline" /> 
                    <telerik:AjaxUpdatedControl ControlID="btnOk" UpdatePanelRenderMode="Inline" /> 
                </UpdatedControls> 
            </telerik:AjaxSetting> 
            <telerik:AjaxSetting AjaxControlID="radNumber2"
                <UpdatedControls> 
                    <telerik:AjaxUpdatedControl ControlID="lblTotal" UpdatePanelRenderMode="Inline" /> 
                    <telerik:AjaxUpdatedControl ControlID="btnOk" UpdatePanelRenderMode="Inline" /> 
                </UpdatedControls> 
            </telerik:AjaxSetting> 
            <telerik:AjaxSetting AjaxControlID="btnOk"
                <UpdatedControls> 
                    <telerik:AjaxUpdatedControl ControlID="lblMessage" UpdatePanelRenderMode="Inline" /> 
                </UpdatedControls> 
            </telerik:AjaxSetting> 
        </AjaxSettings> 
    </telerik:RadAjaxManager> 
    
    <div style="margin:50px" > 
        <telerik:RadNumericTextBox ID="radNumber1" runat="server" Type="Number" MinValue="1" 
            AutoPostBack="true" NumberFormat-DecimalDigits="0" Width="75px" ShowSpinButtons="true" 
            Value="1" OnTextChanged="OnNumber1Changed" /> 
        plus 
        <telerik:RadNumericTextBox ID="radNumber2" runat="server" Type="Number" MinValue="1" 
            AutoPostBack="true" NumberFormat-DecimalDigits="0" Width="75px" ShowSpinButtons="true" 
            Value="1" OnTextChanged="OnNumber2Changed" /> 
        equals 
        <asp:Label runat="server" ID="lblTotal"></asp:Label>
        <p> 
            Message: 
            <asp:Label ID="lblMessage" runat="server" Text="..."></asp:Label> 
        </p> 
        <p> 
            <asp:Button runat="server" ID="btnOk" OnClick="btnOk_Click" Text="OK" /> 
        </p> 
    </div> 
    </form> 
</body> 
</html> 
 

using System; 
using Telerik.Web.UI; 
 
namespace Ajax 
    public partial class RadAjaxProblem : System.Web.UI.Page 
    { 
        protected void Page_Load(object sender, EventArgs e) 
        { 
 
        } 
 
        private void UpdateTotal() 
        { 
            int arg1 = (int) (radNumber1.Value.HasValue ? radNumber1.Value.Value : 0); 
            int arg2 = (int) (radNumber2.Value.HasValue ? radNumber2.Value.Value : 0); 
            lblTotal.Text = String.Format("{0}", arg1 + arg2); 
        } 
 
        protected void OnNumber1Changed(object sender, EventArgs e) 
        { 
            UpdateTotal(); 
        } 
        protected void OnNumber2Changed(object sender, EventArgs e) 
        { 
            UpdateTotal(); 
        } 
 
 
        protected void RadAjaxManager1_AjaxRequest(object sender, AjaxRequestEventArgs e) 
        { 
             
        } 
 
        protected void btnOk_Click(object sender, EventArgs e) 
        { 
             
            lblMessage.Text = String.Format("OK clicked at " + DateTime.Now.ToLongTimeString()); 
        } 
    } 
 
Dürdane
Top achievements
Rank 1
 answered on 10 Jul 2016
1 answer
138 views

Hello

On a page I have RadNavigation menu with submenu and a AutoCompleteBox with OnEntryAdded event. If I put the AutoCompleteBox inside the UpdatePanel, after OnEntryAdded is fired, RadNavigation menu does not work anymore - it's blocked, I can't access submenu nodes. There is no javascript errors on the page, so I don't know how to fix this. Can you help me please.

I'm attaching the sample code which you can use to see the issue.

<%@ Page Title="" Language="VB"  AutoEventWireup="false" CodeFile="test1.aspx.vb" Inherits="test1" %>
<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
<!DOCTYPE html>
<html>
    <head>
        <title>Test</title>
    </head>
    <body>
          <form id="form1" enctype="multipart/form-data"  runat="server">

        <telerik:RadScriptManager ID="RadScriptManager1" EnableScriptGlobalization="true"  Runat="server">
        </telerik:RadScriptManager>
               <telerik:RadNavigation ID="radNav"  Skin="MetroTouch" Font-Size="Medium"  runat="server" RenderMode="Auto">
                <Nodes>
                    <telerik:NavigationNode Text="Test">
                        <Nodes>
                        <telerik:NavigationNode NavigateUrl="test1.aspx"  Text="Test 1"></telerik:NavigationNode>
                        <telerik:NavigationNode NavigateUrl="test1.aspx"  Text="Test 2"></telerik:NavigationNode>
                        </Nodes>
                    </telerik:NavigationNode>
                </Nodes>
                </telerik:RadNavigation>

              <asp:UpdatePanel runat="server" ID="up1">
                  <ContentTemplate>
                        <telerik:RadAutoCompleteBox  OnEntryAdded="drpLista_EntryAdded"  ID="RadAutoCompleteBox1" Width="180px"  runat="server" Skin="Bootstrap">
                        </telerik:RadAutoCompleteBox> 
                  </ContentTemplate>
              </asp:UpdatePanel>
                   

              </form>
    </body>
</html>

 

Imports System.Data
Imports System.Data.SqlClient
Imports Telerik.Web.UI

Partial Class test1
    Inherits System.Web.UI.Page

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load
        BindToArrayList(RadAutoCompleteBox1)
    End Sub 'Page_Load


    Private Sub BindToArrayList(ByVal autoCompleteBox As RadAutoCompleteBox)
        Dim itemsList As New ArrayList()
        itemsList.Add("One")
        itemsList.Add("Two")
        itemsList.Add("Three")
        autoCompleteBox.DataSource = itemsList
    End Sub 'BindToArrayList

    Protected Sub drpLista_EntryAdded(sender As Object, e As AutoCompleteEntryEventArgs)
        
    End Sub


End Class

Peter Milchev
Telerik team
 answered on 08 Jul 2016
3 answers
80 views

On Firefox the Radeditor imagemanager window is:

 

1. Always sticking on top of browserwindow

2. not high enough for content, see screenshot.

Marc
Vessy
Telerik team
 answered on 08 Jul 2016
6 answers
285 views
01. protected void RDDL_Statut_Load(object sender, EventArgs e)
02.{
03.    DC_FiltragesDataContext Mydb = new DC_FiltragesDataContext();
04.    var results = (from U in Mydb.PLOP
05.                   select new { statut = U.STATUT}).Distinct();
06. 
07.    RDDL_Statut.DataSource = results;
08.    RDDL_Statut.DataTextField = "statut";
09.    RDDL_Statut.DataValueField = "statut";
10. 
11.    RDDL_Statut.DataBind();
12.    RDDL_Statut.Items.Insert(0, new DropDownListItem("--ALL STATUT--", "ALL"));
13. 
14.}

            Hi, I have an issue with my drop down list.

Lets say that i have a DropDownList Displaying : A, B ,C , D etc. And I need a default item.
Using this code , my data is not correctly bound.
The display of the DrowDownList Is the one i expected . But my "RDDL_Statut.SelectedItem.Value.ToString()" Is returning the Next Index.
When A is clicked I get B value.


Ivan Danchev
Telerik team
 answered on 08 Jul 2016
Narrow your results
Selected tags
Tags
+? more
Top users last month
Top achievements
Rank 1
Iron
Iron
Iron
Rob
Top achievements
Rank 3
Bronze
Bronze
Iron
ivory
Top achievements
Rank 1
Iron
Nurik
Top achievements
Rank 2
Iron
Iron
YF
Top achievements
Rank 1
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Top achievements
Rank 1
Iron
Iron
Iron
Rob
Top achievements
Rank 3
Bronze
Bronze
Iron
ivory
Top achievements
Rank 1
Iron
Nurik
Top achievements
Rank 2
Iron
Iron
YF
Top achievements
Rank 1
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?