Telerik Forums
UI for ASP.NET AJAX Forum
2 answers
127 views
Dear Telerik Team,

Though I have asp:RequiredFieldValidator to validate fields in inline edit form, when I click submit button validators doesn't stop postback when field value is empty.

I look forward to have your assistance. I can provide other page if required.

Regards

Pathan L.

<code>
<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
<telerik:RadCodeBlock runat="server" ID="radCodeBlock">

    <script type="text/javascript">

        function onAddressRadToolBarButtonClicking(sender, args) {
            var masterTableViewAddress = getMaterTableViewAddress();
            if (masterTableViewAddress != null) {
                var comandNameAddress = args.get_item().get_commandName();
                if (comandNameAddress == 'Delete') {
                    if (masterTableViewAddress.get_selectedItems().length > 0) {
                        args.set_cancel(!confirm('Are you sure you want to delete selected address/s?'));
                    }
                    else {
                        alert('You must select a grid row first before processing delete.');
                        args.set_cancel(true);
                    }
                }
                else if (comandNameAddress == 'ToggleFilterBar') {
                if (masterTableViewAddress.get_isFilterItemVisible()) {
                        hideFilterItemAddress(masterTableViewAddress);
                    }
                    else {
                        showFilterItemAddress(masterTableViewAddress);
                    }
                    args.set_cancel(true);
                }
            }
        }


        function getMaterTableViewAddress() {
            var gridAddress = $find("<%=rdgAddressGrid.ClientID %>");
            return gridAddress.get_masterTableView();
        }


        function showFilterItemAddress(masterTableViewAddress) {
            masterTableViewAddress.showFilterItem();
        }
        
        function hideFilterItemAddress(masterTableViewAddress) {
            masterTableViewAddress.hideFilterItem();
        } 
    </script>


</telerik:RadCodeBlock>
<telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanelAddress" runat="server" Skin="Vista">
</telerik:RadAjaxLoadingPanel>
<telerik:RadGrid ID="rdgAddressGrid" runat="server" Skin="Vista" AllowPaging="True"
    AllowSorting="True" AllowMultiRowSelection="true" AutoGenerateColumns="False"
    OnNeedDataSource="rdgAddressGrid_NeedDataSource" Width="99%" ShowStatusBar="True"
    GridLines="None" PageSize="5" AllowFilteringByColumn="true" OnItemCommand="rdgAddressGrid_ItemCommand"
    EnableViewState="true" OnItemDataBound="rdgAddressGrid_ItemDataBound" 
    OnPreRender="rdgAddressGrid_PreRender" onload="rdgAddressGrid_Load">
    <ValidationSettings EnableValidation="true" ValidationGroup="AddressGrid" CommandsToValidate="PerformInsert, Update" />
    <PagerStyle Mode="NextPrevAndNumeric" AlwaysVisible="true" PrevPageToolTip="Previous"
        NextPagesToolTip="Next" />
    <MasterTableView EditMode="EditForms" Name="mtvPhone" CommandItemDisplay="Top" DataKeyNames="intAddressID, intStudentID">
    <ExpandCollapseColumn FilterControlAltText="Filter ExpandColumn column"></ExpandCollapseColumn>
        <Columns>
            <telerik:GridClientSelectColumn UniqueName="CheckboxSelectColumn" ItemStyle-HorizontalAlign="Left">
                <HeaderStyle Width="25px" />
                <ItemStyle HorizontalAlign="Center" />
            </telerik:GridClientSelectColumn>
            <telerik:GridEditCommandColumn ButtonType="ImageButton" UniqueName="EditCommandColumn">
                <HeaderStyle Width="30px" />
                <ItemStyle HorizontalAlign="Center" />
            </telerik:GridEditCommandColumn>
            <telerik:GridCheckBoxColumn DataField="ysnPrimaryAddress" ConvertEmptyStringToNull="true"
                DefaultInsertValue="false" HeaderText="Primary" SortExpression="ysnPrimaryAddress"
                UniqueName="ysnPrimaryAddress" HeaderTooltip="Primary" AllowFiltering="false">
                <HeaderStyle Width="50px" />
                <ItemStyle HorizontalAlign="Center" />
            </telerik:GridCheckBoxColumn>
            <telerik:GridBoundColumn DataField="strAddressType" HeaderText="Address Type" SortExpression="strAddressType"
                UniqueName="strAddressType" HeaderTooltip="Address Type" CurrentFilterFunction="Contains">
                <HeaderStyle Width="90px" />
            </telerik:GridBoundColumn>
            <telerik:GridBoundColumn DataField="strAddress1" HeaderText="Address 1" SortExpression="strAddress1"
                UniqueName="strAddress1" HeaderTooltip="Address 1" CurrentFilterFunction="Contains">
                <HeaderStyle Width="125px" />
            </telerik:GridBoundColumn>
            <telerik:GridBoundColumn DataField="strAddress2" HeaderText="Address 2" SortExpression="strAddress2"
                UniqueName="strAddress2" HeaderTooltip="Address 2" CurrentFilterFunction="Contains">
                <HeaderStyle Width="125px" />
            </telerik:GridBoundColumn>
            <telerik:GridBoundColumn DataField="strStreet" HeaderText="Street" SortExpression="strStreet"
                UniqueName="strStreet" HeaderTooltip="Street" CurrentFilterFunction="Contains">
                <HeaderStyle Width="125px" />
            </telerik:GridBoundColumn>
            <telerik:GridBoundColumn DataField="strCity" HeaderText="City" SortExpression="strCity"
                UniqueName="strCity" HeaderTooltip="City" CurrentFilterFunction="Contains">
                <HeaderStyle Width="90px" />
            </telerik:GridBoundColumn>
        </Columns>


<PagerStyle AlwaysVisible="True"></PagerStyle>
        <CommandItemTemplate>
            <telerik:RadToolBar Skin="Vista" ID="rtbAddressCommand" OnClientButtonClicking="onAddressRadToolBarButtonClicking"
                runat="server" AutoPostBack="true">
                <Items>
                    <telerik:RadToolBarButton Text="Add new address" ID="btnInitInsertAddress" runat="server"
                        CommandName="InitInsert" ImageUrl="~/images/telerik/AddRecord.gif" ImagePosition="Left">
                    </telerik:RadToolBarButton>
                    <telerik:RadToolBarButton Text="Delete address" ID="btnDeleteAddress" runat="server"
                        CommandName="Delete" ImageUrl="~/images/telerik/Delete.gif" ImagePosition="Left">
                    </telerik:RadToolBarButton>
                    <telerik:RadToolBarButton Text="Toggle filtering" ID="ToggleFilteringAddress" runat="server"
                        CommandName="ToggleFilterBar" ImageUrl="~/images/telerik/search.png" ImagePosition="Left">
                    </telerik:RadToolBarButton>
                    <telerik:RadToolBarButton Text="Refresh" ID="btnRefreshAddress" runat="server" CommandName="RebindGrid"
                        ImageUrl="~/images/telerik/Refresh.gif" ImagePosition="Left" CausesValidation="false">
                    </telerik:RadToolBarButton>
                </Items>
            </telerik:RadToolBar>
        </CommandItemTemplate>
        <EditFormSettings ColumnNumber="3" EditFormType="Template" CaptionFormatString="Edit details for Address with ID {0}"
            CaptionDataField="intAddressID">
            <EditColumn ButtonType="ImageButton" InsertText="Insert" UpdateText="Update" UniqueName="EditCommandColumn1"
                CancelText="Cancel">
            </EditColumn>
            <FormTemplate>
                <table width="100%">
                    <tr>
                        <td style="vertical-align: top;">
                            <table border="0" width="80%">
                                <colgroup>
                                    <col width="50%" />
                                    <col width="50%" />
                                </colgroup>
                                <tbody>
                                    <tr>
                                        <td colspan="2" style="font-weight: bold">
                                            <%-- Edit details for Address with ID--%>
                                            <asp:Label ID="lblEditDetails" Text='<%# (Container is GridEditFormInsertItem) ? "" : "Edit details for Address with ID: "+ Eval( "intAddressID") %>'
                                                runat="server"></asp:Label>
                                        </td>
                                    </tr>
                                    <tr>
                                        <td style="vertical-align: top;">
                                            <table border="0" cellspacing="5" cellpadding="5">
                                                <tbody>
                                                    <tr>
                                                        <td align="left">
                                                            <label>
                                                                Is Primary:</label>
                                                        </td>
                                                        <td align="left">
                                                            <asp:CheckBox ID="chkPrimary" Checked='<%#Bind("ysnPrimaryAddress")%>' runat="server" />
                                                        </td>
                                                    </tr>
                                                    <tr>
                                                        <td align="left">
                                                            <label>
                                                                Address Type:</label>
                                                        </td>
                                                        <td>
                                                            <telerik:RadComboBox CssClass="TelerikTextBox2" Width="200px" AccessKey="T" ID="ddlAddressType"
                                                                runat="server" AppendDataBoundItems="True" Filter="Contains" 
                                                                CausesValidation="False" ValidationGroup="AddressGrid">
                                                            </telerik:RadComboBox>
                                                            <br />
                                                            <asp:RequiredFieldValidator ID="rfvAddressType" runat="server" ControlToValidate="ddlAddressType"
                                                                ErrorMessage="Address Type is missing." Display="Dynamic" ValidationGroup="AddressGrid" CssClass="validator">
                                                            </asp:RequiredFieldValidator>
                                                        </td>
                                                    </tr>
                                                    <tr>
                                                        <td align="left">
                                                            <label>
                                                                Address 1:
                                                            </label>
                                                        </td>
                                                        <td align="left">
                                                            <telerik:RadTextBox CssClass="TelerikTextBox2" ID="txtAddress1" Text='<%# Bind( "strAddress1") %>'
                                                                runat="server" Width="200px" MaxLength="50" ValidationGroup="AddressGrid">
                                                            </telerik:RadTextBox><br />
                                                            <asp:RequiredFieldValidator ID="rfvAddress1" runat="server" ControlToValidate="txtAddress1"
                                                                ErrorMessage="Address 1 is missing." Display="Dynamic" CssClass="validator" ValidationGroup="AddressGrid"></asp:RequiredFieldValidator>
                                                        </td>
                                                    </tr>
                                                    <tr>
                                                        <td align="left">
                                                            <label>
                                                                Address 2:</label>
                                                        </td>
                                                        <td align="left">
                                                            <telerik:RadTextBox ID="txtAddress2" CssClass="TelerikTextBox2" Text='<%# Bind( "strAddress2") %>'
                                                                runat="server" Width="200px" MaxLength="50">
                                                            </telerik:RadTextBox>
                                                        </td>
                                                    </tr>
                                                    <tr>
                                                        <td align="left">
                                                            <label>
                                                                Street:</label>
                                                        </td>
                                                        <td align="left">
                                                            <telerik:RadTextBox ID="txtStreet" CssClass="TelerikTextBox2" Text='<%# Bind( "strStreet") %>'
                                                                runat="server" Width="200px" MaxLength="50">
                                                            </telerik:RadTextBox>
                                                        </td>
                                                    </tr>
                                                </tbody>
                                            </table>
                                        </td>
                                        <td style="vertical-align: top;">
                                            <table border="0" cellspacing="5" cellpadding="5">
                                                <tbody>
                                                    <tr>
                                                        <td align="left">
                                                            <label>
                                                                City:</label>
                                                        </td>
                                                        <td align="left">
                                                            <telerik:RadTextBox CssClass="TelerikTextBox2" ID="txtCity" Text='<%# Bind( "strCity") %>'
                                                                runat="server" MaxLength="50" ValidationGroup="AddressGrid">
                                                            </telerik:RadTextBox><br />
                                                            <asp:RequiredFieldValidator ID="rfvCity" runat="server" ControlToValidate="txtCity"
                                                                ErrorMessage="City is missing." Display="Dynamic" CssClass="validator" ValidationGroup="AddressGrid"></asp:RequiredFieldValidator>
                                                        </td>
                                                    </tr>
                                                    <tr>
                                                        <td align="left">
                                                            <label>
                                                                Zip:</label>
                                                        </td>
                                                        <td align="left">
                                                            <telerik:RadTextBox CssClass="TelerikTextBox2" ID="txtZip" Text='<%# Bind("strZip") %>'
                                                                runat="server" MaxLength="50">
                                                            </telerik:RadTextBox><br />
                                                        </td>
                                                    </tr>
                                                    <tr>
                                                        <td align="left">
                                                            <label>
                                                                State:</label>
                                                        </td>
                                                        <td align="left">
                                                            <telerik:RadComboBox CssClass="TelerikTextBox2" Width="130px" Skin="Vista" ID="ddlState"
                                                                runat="server" MarkFirstMatch="true" Filter="Contains" AllowCustomText="false">
                                                                <Items>
                                                                    <telerik:RadComboBoxItem Value="Gujarat" Text="Gujarat" />
                                                                </Items>
                                                            </telerik:RadComboBox>
                                                        </td>
                                                    </tr>
                                                    <tr>
                                                        <td align="left">
                                                            <label>
                                                                Country:</label>
                                                        </td>
                                                        <td align="left">
                                                            <telerik:RadComboBox CssClass="TelerikTextBox2" Width="130px" Skin="Vista" ID="ddlCountry"
                                                                runat="server" MarkFirstMatch="true" Filter="Contains" AllowCustomText="false">
                                                                <Items>
                                                                    <telerik:RadComboBoxItem Value="India" Text="India" />
                                                                </Items>
                                                            </telerik:RadComboBox>
                                                        </td>
                                                    </tr>
                                                </tbody>
                                            </table>
                                        </td>
                                    </tr>
                                    <tr>
                                        <td colspan="2" align="left">
                                            <asp:ImageButton ImageUrl="~/images/telerik/tick.gif" ID="btnUpdate" ValidationGroup="AddressGrid"
                                                CausesValidation="true" runat="server" CommandName='<%# (Container as GridItem).OwnerTableView.IsItemInserted ? "PerformInsert" : "Update" %>'>
                                            </asp:ImageButton>&nbsp;
                                            <asp:ImageButton ID="btnCancel" ImageUrl="~/images/telerik/cancel.gif" runat="server"
                                                CausesValidation="False" CommandName="Cancel"></asp:ImageButton>
                                        </td>
                                    </tr>
                                </tbody>
                            </table>
                        </td>
                    </tr>
                </table>
            </FormTemplate>
        </EditFormSettings>
<CommandItemSettings ExportToPdfText="Export to PDF"></CommandItemSettings>


        <RowIndicatorColumn Visible="false">
        </RowIndicatorColumn>
    </MasterTableView>
    <ClientSettings AllowColumnsReorder="True" AllowKeyboardNavigation="true" AllowAutoScrollOnDragDrop="true"
        ReorderColumnsOnClient="true" AllowDragToGroup="True" EnableRowHoverStyle="true">
        <Selecting AllowRowSelect="True" />
        <Selecting AllowRowSelect="True" />
        <ClientMessages DragToGroupOrReorder="Select All" />
        <Scrolling AllowScroll="true" SaveScrollPosition="true" UseStaticHeaders="true">
        </Scrolling>
        <Resizing AllowColumnResize="true" EnableRealTimeResize="true" AllowRowResize="true" />
    </ClientSettings>
    <FilterMenu EnableEmbeddedSkins="true">
    </FilterMenu>
</telerik:RadGrid>
<asp:SqlDataSource ID="dsAddressType" runat="server" ConnectionString="<%$ ConnectionStrings:NirmalNiketalCNetWeb_ConnectionString %>"
    SelectCommand="usp_GetReferenceChildByParentName" SelectCommandType="StoredProcedure">
    <SelectParameters>
        <asp:Parameter Name="strParentName" Type="String" DefaultValue="AddressType" />
    </SelectParameters>
</asp:SqlDataSource>

<code/>

Vijay
Top achievements
Rank 1
 answered on 11 Sep 2014
15 answers
675 views
Hello All,
               I am trying to export selected values from my grid to a CSV.  All I can manage is to export the entire grid values.
These two links show how to do it. 
http://www.telerik.com/community/forums/aspnet-ajax/grid/exporting-only-selected-rows.aspx
http://www.telerik.com/community/forums/aspnet-ajax/grid/exporting-selected-radgrid-rows-to-excel-csv.aspx

But, unfortunately I am not able to achieve that. I want to export only the rows selected and if none of the rows are selected, I want to export the entire grid. Here is my code
protected void ButtonGo_Click(object sender, EventArgs e)
        {
            if (DropDownList2.SelectedValue == "ExportToCSV")
            {
                foreach (GridDataItem item in RadGrid1.MasterTableView.Items)
                {
                    if (!item.Selected)
                    {
                        item.Visible = false;
                    }
                }
                RadGrid1.ExportSettings.IgnorePaging = true;
                RadGrid1.ExportSettings.FileName = "CanvasData";
                RadGrid1.MasterTableView.ExportToCSV();
            }
        }


Any help is really appreciated.


Kostadin
Telerik team
 answered on 11 Sep 2014
5 answers
119 views
Hello,

I am using RadChart, and when i apply skin ( LightBlue ), i am try change legend color, and no change.
If i no use skin, its work. Else no work.

Anybody can help?

Partof HTML
                            <td colspan="2" align="center">
                                <telerik:RadChart ID="chtDesempenhoProcesso1" runat="server" Width="970px" Height="420px"  OnDataBound="chtDesempenhoProcesso1_DataBound" Skin="LightBlue" AutoTextWrap="true">
                                    <PlotArea>
                                        <EmptySeriesMessage Visible="True">
                                            <Appearance Visible="True">
                                            </Appearance>
                                        </EmptySeriesMessage>
                                        <Appearance>
                                            <Border Width="0" Visible="true" />
                                        </Appearance>
                                        <XAxis DataLabelsColumn="Area">
                                        </XAxis>
                                        <YAxis MinValue="0" MaxValue="100" AutoScale="false" Step="10" Appearance-MinorGridLines-Visible="false" Appearance-MajorGridLines-Visible="false">
                                        </YAxis>
                                    </PlotArea>
                                    <ChartTitle>
                                        <TextBlock Text="Dimensão">
                                        </TextBlock>
                                    </ChartTitle>

                                </telerik:RadChart>
                            </td>

aspx.cs

    protected void chtDesempenhoProcesso1_DataBound(object sender, EventArgs e)
    {
        chtDesempenhoProcesso1.PlotArea.XAxis[0].TextBlock.Appearance.TextProperties.Font = new System.Drawing.Font(new System.Drawing.Font("Arial", 10), System.Drawing.FontStyle.Bold);

        if (chtDesempenhoProcesso1.Chart.PlotArea.XAxis.Items.Count > 0)
        {
            for (int i = 0; i < chtDesempenhoProcesso1.Chart.PlotArea.XAxis.Items.Count; i++)
            {
                ChartSeriesItem item = chtDesempenhoProcesso1.Series[5].Items[i];
                item.Appearance.FillStyle.MainColor = System.Drawing.Color.DarkGray;
                item.Appearance.FillStyle.SecondColor = System.Drawing.Color.Gray;
                item.Appearance.Shadow.Distance = 155;
                item.Appearance.Border.Color = System.Drawing.Color.Gray;

              }
                // This code no change legend color
            chtDesempenhoProcesso1.Series[5].Appearance.FillStyle.MainColor = System.Drawing.Color.DarkGray;
        }

    }

thx..
Danail Vasilev
Telerik team
 answered on 11 Sep 2014
1 answer
90 views
I have an autogeneratedcolumn Radgrid that needs to make one of those column  as a radiobuttonlist(Yes No radiobautons). I don't know how I have to do it? Right now in edit mode everything is a textbox. How can I change the textbox of that special column into radiobutonlist? Would you please help me?

​<telerik:RadGrid ID="QuestionFoundationRadGrid" runat="server" OnNeedDataSource="QuestionFoundationRadGrid_NeedDataSource" OnPreRender="QuestionFoundationRadGrid_PreRender" OnItemCreated="QuestionFoundationRadGrid_ItemCreated" OnUpdateCommand="QuestionFoundationRadGrid_UpdateCommand" OnInsertCommand="QuestionFoundationRadGrid_InsertCommand" OnItemCommand="QuestionFoundationRadGrid_ItemCommand">
<MasterTableView EditMode="PopUp" CommandItemDisplay="Top">
<CommandItemSettings ShowRefreshButton="False" AddNewRecordText="Add New Answer" />
<CommandItemTemplate>
<div style="padding: 5px 5px;">
<table style="width: 100%">
<tr>

<td style="text-align: right">
<asp:LinkButton ID="AddAnswer" runat="server" CommandName="InitInsert"><img style="border:0px;vertical-align:middle;" alt="" runat="server" src="~\Images\AddRecord.png"/>&nbsp;&nbsp;Add New Answer</asp:LinkButton>&nbsp;&nbsp;
</td>
</tr>
</table>
</div>
</CommandItemTemplate>
<RowIndicatorColumn Visible="False">
</RowIndicatorColumn>
<ExpandCollapseColumn Created="True">
</ExpandCollapseColumn>
<Columns>

<telerik:GridEditCommandColumn ButtonType="ImageButton" ColumnGroupName="Actions" HeaderStyle-CssClass="header" UniqueName="EditCommandColumn" >
<HeaderStyle CssClass="header" />
<ItemStyle HorizontalAlign="Center" Width="15" CssClass="MergedBorder"/>

</telerik:GridEditCommandColumn>

<telerik:GridTemplateColumn UniqueName="DeleteColumn" ColumnGroupName="Actions" AllowFiltering="False" >
<ItemTemplate>
<asp:ImageButton ID="DeleteImageButton" runat="server" AlternateText="Delete Toolkit" CommandName="Delete"
OnClientClick="javascript:if(!confirm('This action will delete the selected Answer. Are you sure?')){return false;}"
ImageUrl="~\Images\delete-icon.png" />
</ItemTemplate>
<HeaderStyle CssClass="header" />
<ItemStyle HorizontalAlign="Center" Width="5"/>
</telerik:GridTemplateColumn>

</Columns>
<ColumnGroups>
<telerik:GridColumnGroup HeaderStyle-HorizontalAlign="Center" HeaderText="Actions" Name="Actions" >
<HeaderStyle HorizontalAlign="Center"/>

</telerik:GridColumnGroup>
</ColumnGroups>
<EditFormSettings>
                               
                            </EditFormSettings>

</MasterTableView>
</telerik:RadGrid>
Konstantin Dikov
Telerik team
 answered on 11 Sep 2014
1 answer
83 views
I have a requirement to create a custom button on my toolbar that is wider than the standard button. How do I do this with RadEditor?
Ianko
Telerik team
 answered on 11 Sep 2014
1 answer
103 views
I'm getting an error message when I go to a module that has your AsyncUpload Control in it.  I've attached a screenshot of that message.

In my layout code, I've defined the control thusly:
<telerik:RadAsyncUpload runat="server" ID="radAsyncUpload1" MultipleFileSelection="Disabled" HideFileInput="true" Localization-Select="Import"
                        OnClientFilesUploaded="clientFilesUploaded" OnFileUploaded="radAsyncUpload1_FileUploaded" TemporaryFolder="~/Logs" />
In Visual Studio 2012 it runs fine and I can see that the temporary file is being created.  But when running under IIS this error occurs.

Any ideas how to fix it?

Robert
Robert
Top achievements
Rank 1
 answered on 11 Sep 2014
2 answers
207 views
Hi

My client is asking to use Telerick controls for the project which is in ASP.Net 2.0 framework.Can you please let me know whether it is feasible to use telerikcontrol in ASP.Net 2.0?If yes can you please provide the  Downloadable file.

Thanks
Vamsi
Hafsal
Top achievements
Rank 1
 answered on 10 Sep 2014
7 answers
134 views

Hi,

I am having Pivotgrid row alignment issue when IE8 compatibility View settings turned on. Unfortunately, this is the default setting on all the users machine.

Please find the attached images with / without compatibility settings.

Thanks.
ts
Top achievements
Rank 1
 answered on 10 Sep 2014
1 answer
221 views
In which cases the above situation is true?

I change a parameter of the SqlCommand which passes its data to the DataSouce of the grid and then I rebind.
I stop the code where I check the count of the items in the MasterTableView and I see that it's not zero.

I can even select the first row by...
RadGrid.MasterTableView.Items(0).Selected = True

...and I can see the data in the grid object, like
RadGrid.SelectedItems.Item(0).Cells(2).Text (contains the expected value)

But the grid on the screen remains empty.

Where should I look?

Jayesh Goyani
Top achievements
Rank 2
 answered on 10 Sep 2014
6 answers
172 views
I have couple of issues related to dynamically created Radgrid.
Background: I have created a dynamic Radgrid which contains Templatecolumn in it, this template columns hold three dropdown list controls which work in a cascading manner. I'm pre-selecting the drop down and for new records its getting default selections. Everything works fine until I get into paging.

Issues: 1. Whenever I use paging the page number is selected in the grid but it always shows first page records.
            2. The selections made in previous page dropdown list are not persisting during the paging.

I'm not sure if both are related to same thing. Here is my code for your reference. Your help is highly appreciated.

 
protected override void OnInit(EventArgs e)
        {
            base.OnInit(e);
         AddGrid();
        }
 
 private void AddGrid()
        {
 
        _grid = new RadGrid
            {
                ID = "TestGrid",
                PageSize = 30,
                ShowGroupPanel = false,
                AllowSorting = false,
                AllowPaging = true,
                AutoGenerateColumns = false,
                GridLines = GridLines.Vertical,
                VirtualItemCount =0               
            };
 
        _grid.ClientSettings.AllowDragToGroup = false;
             _grid.ClientSettings.AllowColumnsReorder = false;
             _grid.ClientSettings.AllowColumnHide = true;
             _grid.ClientSettings.Animation.AllowColumnReorderAnimation = false;
              _grid.ClientSettings.Animation.AllowColumnRevertAnimation = false;
 
              _grid.MasterTableView.DataKeyNames = new[] { "Id" };
              _grid.MasterTableView.ShowHeadersWhenNoRecords = true;
              _grid.MasterTableView.UseAllDataFields = true;
              _grid.MasterTableView.Name = "Master";
           _grid.ItemDataBound += GridItemDataBound;
 _grid.PageIndexChanged += new GridPageChangedEventHandler_grid_PageIndexChanged);
_grid.NeedDataSource += new GridNeedDataSourceEventHandler(_grid_NeedDataSource);
 
 
 var countryTemplate= new GridTemplateColumn
            {
                UniqueName = "ADDCountry",
                HeaderText = "Country Field",
                Resizable = true,
 
            };
            countryTemplate.HeaderStyle.Font.Bold = true;
            countryTemplate.ItemTemplate = new Templateclass(countryTemplate.UniqueName, ExcelColumns);
 
            _grid.MasterTableView.Columns.Add(sourceTemplate);
 
             
            var stateTemplate = new GridTemplateColumn
            {
                UniqueName = "ADDState",
                HeaderText = "state Column Field",
            };
 
            stateTemplate .HeaderStyle.Font.Bold = true;
stateTemplate .ItemTemplate = new Templateclass(stateTemplate .UniqueName, null);
 
            _grid.MasterTableView.Columns.Add(stateTemplate );
 
 
            var CityTemplate = new GridTemplateColumn
            {
                UniqueName = "ADDCity",
                HeaderText = "Mapping Rule",
            };
 
            CityTemplate .HeaderStyle.Font.Bold = true;
            CityTemplate .ItemTemplate = new Templateclass(CityTemplate .HeaderText, null);
 
            _grid.MasterTableView.Columns.Add(CityTemplate);
 
  Content.Controls.Add(_grid);
        }
 
void _grid_NeedDataSource(object sender, GridNeedDataSourceEventArgs e)
        {
            ((RadGrid)sender).MasterTableView.VirtualItemCount = bindingObject.Count;
            ((RadGrid)sender).CurrentPageIndex = ((RadGrid)sender).MasterTableView.CurrentPageIndex;
            ((RadGrid)sender).DataSource = bindingObject;
            
        }
void _grid_PageIndexChanged(object sender, GridPageChangedEventArgs e)
        {
            ((RadGrid)sender).MasterTableView.CurrentPageIndex = ((RadGrid)sender).CurrentPageIndex;
        }
 
 
 void GridItemCreated(object sender, GridItemEventArgs e)
        {
            if (e.Item is GridDataItem)
            {
                GridDataItem dataItem = (GridDataItem)e.Item;
                DropDownList ddlCountry= (DropDownList)dataItem.FindControl("ddlCountry");
 
                 
 
                if (ddlCountry!= null)
                {
                    ddlCountry.AutoPostBack = true;
 
                    ddlCountry.SelectedIndexChanged += new EventHandler(ddlCountry_SelectedIndexChanged);
 
 
                }
            }
        }
 
public class Templateclass: ITemplate
    {
public Templateclass(string colNames,List<string> CountryNames)
        {
            colName = colNames;
                       countryNames= CountryNames;
        }
 
public void InstantiateIn(Control container)
        {
//create a drop down controls for template columns
}
Jayesh Goyani
Top achievements
Rank 2
 answered on 10 Sep 2014
Narrow your results
Selected tags
Tags
+? more
Top users last month
Rob
Top achievements
Rank 3
Iron
Iron
Iron
Atul
Top achievements
Rank 1
Iron
Iron
Iron
Alexander
Top achievements
Rank 1
Veteran
Iron
Serkan
Top achievements
Rank 1
Iron
Shawn
Top achievements
Rank 1
Iron
Iron
Want to show your ninja superpower to fellow developers?
Top users last month
Rob
Top achievements
Rank 3
Iron
Iron
Iron
Atul
Top achievements
Rank 1
Iron
Iron
Iron
Alexander
Top achievements
Rank 1
Veteran
Iron
Serkan
Top achievements
Rank 1
Iron
Shawn
Top achievements
Rank 1
Iron
Iron
Want to show your ninja superpower to fellow developers?
Want to show your ninja superpower to fellow developers?