This is a migrated thread and some comments may be shown as answers.

[Solved] Sorting and paging dynamically build RadGrid

16 Answers 420 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Galina Grimberg
Top achievements
Rank 1
Galina Grimberg asked on 26 Jun 2009, 07:56 PM

I dynamically  build my  RadGrid, but it lost sorting and paging functionality.

How can I program it?

This is my code;

Aspx page:


<telerik:RadGrid ID="RadGrid1" runat="server" Style="margin-bottom: 0px" 

            EnableViewState="true"   Width="1145px" AllowPaging="True" AllowSorting="True" Skin="Gray"

            DataSourceID="SqlDataSource1" AutoGenerateColumns="False" >

            <HeaderContextMenu>

                <CollapseAnimation Type="OutQuint" Duration="200"></CollapseAnimation>

            </HeaderContextMenu>

            <MasterTableView>                      

                <RowIndicatorColumn>

                    <HeaderStyle Width="20px"></HeaderStyle>

                </RowIndicatorColumn>

                <ExpandCollapseColumn>

                    <HeaderStyle Width="20px"></HeaderStyle>

                </ExpandCollapseColumn>

            </MasterTableView>

            <FilterMenu>

                <CollapseAnimation Type="OutQuint" Duration="200"></CollapseAnimation>

            </FilterMenu>

        </telerik:RadGrid>

    </div>

    <asp:SqlDataSource ID="SqlDataSource1" runat="server" ></asp:SqlDataSource>

 

Vb page

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

        If (Not IsPostBack) Then

            Loaddata()

        End If

    End Sub

 

    Private Sub Loaddata()

        Dim strSQl As String

        strSQl = "Select Pro ,ShipperName as [Shipper Name],BL as [Bill of Lading],convert(varchar(10),PUDate,101) as [Pickup Date]," & _

           " ConsigneeName as Consignee, PO as [Purchase Order],convert(varchar(10),DELDate,101) as [Delivery Date]," & _

           " convert(varchar(10),convert(money,charge))as Charge, ConsigneeCode,ShipperCode,DateInvoiced,BillToCode,PmtType,t.COMPANY," & _

           " c.ThirdPartyFlag as thirdPartyFlag from ShipmentTracking.dbo.ltlprodata3 as t with (nolock) " & _

           " inner join CustomerMaster.dbo.MainframeCustomers as c with (nolock) " & _

           " on (c.company = t.company and t.billtocode = c.[cust no]) " & _

           " where ( DELDATE >= '5/26/2009' and DELDATE <= '6/26/2009' and t.company='p1')  and " & _

           " ((pmttype ='P' and (ShipperCode = 'FEED84' or BillToCode = 'FEED84') and c.ThirdPartyFlag = 0) " & _

           " or (pmttype ='C' and (ConsigneeCode = 'FEED84' or BillToCode = 'FEED84') and c.ThirdPartyFlag = 0) " & _

           " or (pmttype <> 'F' and BillToCode = 'FEED84' and c.ThirdPartyFlag = 1)) " & _

           " ORDER BY Pro;"

 

        FillGrid(strSQl)

    End Sub

 

Sub FillGrid(ByVal strSQL As String)

 

        Dim dbcon As New SqlConnection

        Dim dbCommand As New SqlCommand

        Dim strConnectionString As String

        Dim errHandler As New ErrorHandler

        Dim SQLEscape As New SQLEscape

        Dim rdr As SqlDataReader

        strConnectionString = System.Configuration.ConfigurationManager.AppSettings.Get("GenericDB")

        dbcon.ConnectionString = strConnectionString

        dbcon.Open()

        'cmd = New SqlCommand

        dbCommand.Connection = dbcon

 

        dbCommand.CommandType = CommandType.Text

        dbCommand.CommandText = strSQL

 

        rdr = dbCommand.ExecuteReader()

 

 

        'RadGrid1.Columns.Clear()

 

 

        SqlDataSource1.ConnectionString = strConnectionString

        SqlDataSource1.SelectCommand = strSQL

 

        Dim Pro As New GridHyperLinkColumn

        Dim dataNavigateUrlFields() As String = {"Pro"}

        Pro.DataTextField = "Pro"

        Pro.DataNavigateUrlFields = dataNavigateUrlFields

        Pro.HeaderText = "Pro"

        Pro.SortExpression = "Pro"

        Pro.DataNavigateUrlFormatString = "../MyPyle/MyPyleLTLTracking.aspx?Pro={0}"

        '***************

 

 

        Dim Shipper As New GridHyperLinkColumn

        Dim dataNavigateUrlFields1() As String = {"Shipper", "ShipperCode"}

        Shipper.ItemStyle.HorizontalAlign = HorizontalAlign.Left

        Shipper.DataTextField = "[Shipper Name]"

        Shipper.SortExpression = "Shipper"

        Shipper.DataNavigateUrlFields = dataNavigateUrlFields1

        Shipper.HeaderText = "Shipper"

        Shipper.Target = "_blank"

        Shipper.DataNavigateUrlFormatString = "../publicdocs/WhoAmI.aspx?Account=P1{0}"

 

 

        Dim ShipperCode As New GridBoundColumn

        ShipperCode.ItemStyle.HorizontalAlign = HorizontalAlign.Left

        ShipperCode.DataField = "ShipperCode"

        ShipperCode.HeaderText = "ShipperCode"

        Shipper.DataNavigateUrlFormatString = "../publicdocs/WhoAmI.aspx?Account=P1{1}"

 

        Dim Consignee As New GridHyperLinkColumn

        Dim dataNavigateUrlFields2() As String = {"Consignee", "ConsigneeCode"}

        Consignee.ItemStyle.HorizontalAlign = HorizontalAlign.Left

        Consignee.DataTextField = "Consignee"

        Consignee.SortExpression = "Consignee"

        Consignee.DataNavigateUrlFields = dataNavigateUrlFields2

        Consignee.HeaderText = "Consignee"

        Consignee.Target = "_blank"

        Consignee.DataNavigateUrlFormatString = "../publicdocs/WhoAmI.aspx?Account=P1{0}"

 

        Dim ConsigneeCode As New GridBoundColumn

        ConsigneeCode.ItemStyle.HorizontalAlign = HorizontalAlign.Left

        ConsigneeCode.DataField = "ConsigneeCode"

        ConsigneeCode.HeaderText = "ConsigneeCode"

        Consignee.DataNavigateUrlFormatString = "../publicdocs/WhoAmI.aspx?Account=P1{1}"

 

        Dim BillofLading As New GridBoundColumn

        BillofLading.DataField = "Bill of Lading"

        BillofLading.SortExpression = "Bill of Lading"

        BillofLading.HeaderText = "Bill of Lading"

        BillofLading.ItemStyle.HorizontalAlign = HorizontalAlign.Left

 

        Dim PickupDate As New GridBoundColumn

        PickupDate.ItemStyle.HorizontalAlign = HorizontalAlign.Left

        PickupDate.DataField = "Pickup Date"

        PickupDate.HeaderText = "Pickup Date"

        PickupDate.SortExpression = "Pickup Date"

 

        Dim PurchaseOrder As New GridBoundColumn

        PurchaseOrder.ItemStyle.HorizontalAlign = HorizontalAlign.Left

        PurchaseOrder.DataField = "Purchase Order"

        PurchaseOrder.HeaderText = "Purchase Order"

        PurchaseOrder.SortExpression = "Purchase Order"

 

        Dim DeliveryDate As New GridBoundColumn

        DeliveryDate.ItemStyle.HorizontalAlign = HorizontalAlign.Left

        DeliveryDate.DataField = "Delivery Date"

        DeliveryDate.SortExpression = "Delivery Date"

        DeliveryDate.HeaderText = "Delivery Date"

 

        Dim charge As New GridHyperLinkColumn

        charge.ItemStyle.HorizontalAlign = HorizontalAlign.Left

        Dim dataNavigateUrlFields3() As String = {"charge"}

        charge.DataTextField = "Charge"

        charge.SortExpression = "Charge"

        charge.DataNavigateUrlFields = dataNavigateUrlFields

        charge.HeaderText = "Charge"

        charge.Target = "_blank"

        charge.DataNavigateUrlFormatString = "../MyPyle/InvoicePDFGenerator.aspx?Pro={0}"

 

        Me.RadGrid1.MasterTableView.Columns.Add(Pro)

        Me.RadGrid1.MasterTableView.Columns.Add(ShipperCode)

        Me.RadGrid1.MasterTableView.Columns.Add(Shipper)

        Me.RadGrid1.MasterTableView.Columns.Add(BillofLading)

        Me.RadGrid1.MasterTableView.Columns.Add(PickupDate)

        Me.RadGrid1.MasterTableView.Columns.Add(Consignee)

        Me.RadGrid1.MasterTableView.Columns.Add(PurchaseOrder)

        Me.RadGrid1.MasterTableView.Columns.Add(DeliveryDate)

        Me.RadGrid1.MasterTableView.Columns.Add(charge)

 

 

        Dim objDR As System.Data.DataRow

        Dim objDT As System.Data.DataTable

        Dim srtDV As System.Data.DataView

        objDT = New System.Data.DataTable("Charges")

 

        ' create data table

        objDT.Columns.Add("Pro", GetType(String))

        objDT.Columns.Add("shippercode", GetType(String))

        objDT.Columns.Add("Shipper", GetType(String))

        objDT.Columns.Add("Bill of Lading", GetType(String))

        objDT.Columns.Add("Pickup Date", GetType(String))

        objDT.Columns.Add("ConsigneeCode", GetType(String))

        objDT.Columns.Add("Purchase Order", GetType(String))

        objDT.Columns.Add("Delivery Date", GetType(String))

        objDT.Columns.Add("charge", GetType(String))

        objDT.Columns.Add("consignee", GetType(String))

 

        If rdr.HasRows Then

            Do While rdr.Read

                objDR = objDT.NewRow

                objDR("Pro") = rdr(0)

                objDR("shippercode") = rdr(9)

                objDR("Shipper") = rdr(1)

                objDR("Bill of Lading") = rdr(2)

                objDR("Pickup Date") = rdr(3)

                objDR("ConsigneeCode") = rdr(8)

                objDR("Purchase Order") = rdr(5)

                objDR("Delivery Date") = rdr(6)

                If IsDBNull(rdr(7)) Then

                    objDR("charge") = 0

                Else

                    objDR("charge") = rdr(7)

                End If

                objDR("consignee") = rdr(4)

 

                objDT.Rows.Add(objDR)

                'End If

            Loop

        End If

 

        srtDV = objDT.DefaultView

        srtDV.Sort = "Pro"

        Session("dt") = objDT         

 

        RadGrid1.DataBind()

 

    End Sub

Someone suggested to create datatable and dataview, because you can only sort on dataview, I tried  to add some code on, but nothing happened  

    Protected Sub RadGrid1_SortCommand(ByVal source As Object, ByVal e As Telerik.Web.UI.GridSortCommandEventArgs) Handles RadGrid1.SortCommand

        Response.Write("Sort")

 

 

        'Dim tableView As GridTableView = e.Item.OwnerTableView

 

        'If tableView.DataSourceID = "SqlDataSource1" AndAlso e.SortExpression = "Pro" Then e.Canceled = True

 

        'Dim expression As New GridSortExpression()

 

        'expression.FieldName = "Pro"

        'If tableView.SortExpressions.Count = 0 OrElse _

        '   tableView.SortExpressions(0).FieldName <> "Pro" Then

        '    expression.SortOrder = GridSortOrder.Descending

        'ElseIf tableView.SortExpressions(0).SortOrder = GridSortOrder.Descending Then

        '    expression.SortOrder = GridSortOrder.Ascending

        'ElseIf tableView.SortExpressions(0).SortOrder = GridSortOrder.Ascending Then

        '    expression.SortOrder = GridSortOrder.None

        'End If

        'tableView.SortExpressions.AddSortExpression(expression)

        'tableView.Rebind()

 

        'Loaddata()      

 

    End Sub

Thank you.
Galina

16 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 29 Jun 2009, 10:30 AM
Hi,

When you statically declare a grid columns should be added to the collection first, before the values for their properties are set. This is important because no ViewState is managed for the object before it has been added to the corresponding collection.


Dynamically defining the structure of a statically-declared grid


Thanks,
Princy
0
Galina Grimberg
Top achievements
Rank 1
answered on 29 Jun 2009, 12:12 PM
Thank you,
but how to sort and page after grid columns added to the collection?
Thank you.
GAlina 
0
Pavlina
Telerik team
answered on 29 Jun 2009, 04:19 PM
Hi Galina,

I am sending you a simple working project which handles the desired functionality. Please give it a try and see if this is the expected behavior.

I hope this helps.

Regards,
Pavlina
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Galina Grimberg
Top achievements
Rank 1
answered on 29 Jun 2009, 07:04 PM
Pavlina,

You example works perfectly fine, But in my case I only have

Aspx page

  <telerik:RadGrid ID="RadGrid2" runat="server" DataSourceID="SqlDataSource1" > <asp:SqlDataSource ID="SqlDataSource1" runat="server"></asp:SqlDataSource>

I need to build my grid programmaticly because I have 5 different select statements based which option user will select.

Sub FillGrid(ByVal strSQL As String)

 

        Dim dbcon As New SqlConnection

        Dim dbCommand As New SqlCommand

        Dim strConnectionString As String

        Dim errHandler As New ErrorHandler

        Dim SQLEscape As New SQLEscape

        Dim rdr As SqlDataReader

        strConnectionString = System.Configuration.ConfigurationManager.AppSettings.Get("GenericDB")

        dbcon.ConnectionString = strConnectionString

        dbcon.Open()

        'cmd = New SqlCommand

        dbCommand.Connection = dbcon

 

        dbCommand.CommandType = CommandType.Text

        dbCommand.CommandText = strSQL

 

        rdr = dbCommand.ExecuteReader()

 

        SqlDataSource1.ConnectionString = strConnectionString

        SqlDataSource1.SelectCommand = strSQL

 

        RadGrid1.Columns.Clear()

 

        RadGrid1.MasterTableView.DataKeyNames = New String() {"Pro"}

        RadGrid1.Width = Unit.Percentage(80)

        RadGrid1.PageSize = 5

        RadGrid1.AllowPaging = True

        RadGrid1.PagerStyle.Mode = GridPagerMode.NextPrevNumericAndAdvanced

        RadGrid1.AutoGenerateColumns = False

 

        Dim hyperLinkColumn As GridHyperLinkColumn

        hyperLinkColumn = New GridHyperLinkColumn()

        RadGrid1.MasterTableView.Columns.Add(hyperLinkColumn)

        Dim dataNavigateUrlFields() As String = {"Pro"}

        hyperLinkColumn.DataTextField = "Pro"

        hyperLinkColumn.DataNavigateUrlFields = dataNavigateUrlFields

        hyperLinkColumn.HeaderText = "Pro"

        hyperLinkColumn.SortExpression = "Pro"

        hyperLinkColumn.DataNavigateUrlFormatString = "../MyPyle/MyPyleLTLTracking.aspx?Pro={0}"

        '***************

 

 

        'Dim Shipper As New GridHyperLinkColumn

        hyperLinkColumn = New GridHyperLinkColumn()

        RadGrid1.MasterTableView.Columns.Add(hyperLinkColumn)

        Dim dataNavigateUrlFields1() As String = {"Shipper", "ShipperCode"}

        hyperLinkColumn.ItemStyle.HorizontalAlign = HorizontalAlign.Left

        hyperLinkColumn.DataTextField = "[Shipper Name]"

        'hyperLinkColumn.SortExpression = "Shipper"

        hyperLinkColumn.DataNavigateUrlFields = dataNavigateUrlFields1

        hyperLinkColumn.HeaderText = "Shipper"

        hyperLinkColumn.Target = "_blank"

        hyperLinkColumn.DataNavigateUrlFormatString = "../publicdocs/WhoAmI.aspx?Account=P1{0}"

 

 

        Dim boundColumn As GridBoundColumn

        'boundColumn = New GridBoundColumn()

        'RadGrid1.MasterTableView.Columns.Add(boundColumn)

        'boundColumn.ItemStyle.HorizontalAlign = HorizontalAlign.Left

        'boundColumn.DataField = "ShipperCode"

        'boundColumn.HeaderText = "ShipperCode"

        hyperLinkColumn.DataNavigateUrlFormatString = "../publicdocs/WhoAmI.aspx?Account=P1{1}"

 

        'Dim Consignee As New GridHyperLinkColumn

        hyperLinkColumn = New GridHyperLinkColumn()

        RadGrid1.MasterTableView.Columns.Add(hyperLinkColumn)

        Dim dataNavigateUrlFields2() As String = {"Consignee", "ConsigneeCode"}

        'hyperLinkColumn.ItemStyle.HorizontalAlign = HorizontalAlign.Left

        hyperLinkColumn.DataTextField = "Consignee"

        hyperLinkColumn.SortExpression = "Consignee"

        hyperLinkColumn.DataNavigateUrlFields = dataNavigateUrlFields2

        hyperLinkColumn.HeaderText = "Consignee"

        hyperLinkColumn.Target = "_blank"

        hyperLinkColumn.DataNavigateUrlFormatString = "../publicdocs/WhoAmI.aspx?Account=P1{0}"

 

        ' boundColumn = New GridBoundColumn()

        'RadGrid1.MasterTableView.Columns.Add(boundColumn)

        'boundColumn.ItemStyle.HorizontalAlign = HorizontalAlign.Left

        ' boundColumn.DataField = "ConsigneeCode"

        ' boundColumn.HeaderText = "ConsigneeCode"

        hyperLinkColumn.DataNavigateUrlFormatString = "../publicdocs/WhoAmI.aspx?Account=P1{1}"

 

        ' Dim BillofLading As New GridBoundColumn

        boundColumn = New GridBoundColumn()

        RadGrid1.MasterTableView.Columns.Add(boundColumn)

        boundColumn.DataField = "Bill of Lading"

        boundColumn.SortExpression = "Bill of Lading"

        boundColumn.HeaderText = "Bill of Lading"

        boundColumn.ItemStyle.HorizontalAlign = HorizontalAlign.Left

 

        'Dim PickupDate As New GridBoundColumn

        ' PickupDate.ItemStyle.HorizontalAlign = HorizontalAlign.Left

        boundColumn = New GridBoundColumn()

        RadGrid1.MasterTableView.Columns.Add(boundColumn)

        boundColumn.DataField = "Pickup Date"

        boundColumn.HeaderText = "Pickup Date"

        boundColumn.SortExpression = "Pickup Date"

 

        ' Dim PurchaseOrder As New GridBoundColumn

        boundColumn = New GridBoundColumn()

        RadGrid1.MasterTableView.Columns.Add(boundColumn)

        boundColumn.ItemStyle.HorizontalAlign = HorizontalAlign.Left

        boundColumn.DataField = "Purchase Order"

        boundColumn.HeaderText = "Purchase Order"

        boundColumn.SortExpression = "Purchase Order"

 

        ' Dim DeliveryDate As New GridBoundColumn

        boundColumn = New GridBoundColumn()

        RadGrid1.MasterTableView.Columns.Add(boundColumn)

        boundColumn.ItemStyle.HorizontalAlign = HorizontalAlign.Left

        boundColumn.DataField = "Delivery Date"

        boundColumn.SortExpression = "Delivery Date"

        boundColumn.HeaderText = "Delivery Date"

 

        'Dim charge As New GridHyperLinkColumn

        'charge.ItemStyle.HorizontalAlign = HorizontalAlign.Left

        hyperLinkColumn = New GridHyperLinkColumn()

        RadGrid1.MasterTableView.Columns.Add(hyperLinkColumn)

        Dim dataNavigateUrlFields3() As String = {"charge"}

        hyperLinkColumn.DataTextField = "Charge"

        hyperLinkColumn.SortExpression = "Charge"

        hyperLinkColumn.DataNavigateUrlFields = dataNavigateUrlFields

        hyperLinkColumn.HeaderText = "Charge"

        hyperLinkColumn.Target = "_blank"

        hyperLinkColumn.DataNavigateUrlFormatString = "../MyPyle/InvoicePDFGenerator.aspx?Pro={0}"       

 

        RadGrid1.DataBind()

    End Sub

How can I sort and page. Should  I try to build Grid differently?

Thank you.

Galina

0
Pavlina
Telerik team
answered on 30 Jun 2009, 03:53 PM
Hello Galina,

I am not sure if I understand your scenario completely. Could you please tell me what is the difference between the project I sent you and your scenario? 
It will be best if you open a formal support ticket and send us a simple runnable application demonstrating the problem, so we can check it locally.

Additionally, review the following article which elaborates on this subject:
Programmatic Sorting

Sincerely yours,
Pavlina
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Galina Grimberg
Top achievements
Rank 1
answered on 30 Jun 2009, 07:21 PM

Hi Pavlina.
The difference is that you using select statement on your aspx page

For example: you aspx page

<asp:AccessDataSource ID="AccessDataSource1" runat="server" DataFile="~/App_Data/Nwind.mdb"

            SelectCommand="SELECT * FROM [Customers]"></asp:AccessDataSource>

I’m doing my select on server-site

For example: my aspx  page

<

 

div>

 

 

 

 

 

<asp:SqlDataSource ID="SqlDataSource1" runat="server"></asp:SqlDataSource>

 

 

<telerik:RadScriptManager ID="RadScriptManager1" runat="server" >

 

 

</telerik:RadScriptManager>

 

 

<telerik:RadGrid ID="RadGrid1" runat="server">

 

 

</telerik:RadGrid>

 

 

</div>

 

 

 

 

 

 

When I add my select to the aspx site everyting runs fine, I can sort and page grid, but as soon as I move my select and execute it on server site I’m loosing paging and sorting functionality.

My vb code

 

 

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

 

 

If Not IsPostBack Then

 

 

 

 

 

Dim dbcon As New SqlConnection

 

 

Dim dbCommand As New SqlCommand

 

 

Dim strConnectionString As String = ""

 

 

 

 

 

Dim rdr As SqlDataReader

 

 

Dim strSQL As String = ""

 

 

 

 

strSQL =

"select top 50 * from [WebSiteCustomers] with (nolock)"

 

 

 

 

strConnectionString =

"server=AdpSqlPri;database=CustomerMaster;user id=website;password=zeus9311;"

 

 

 

 

dbcon.ConnectionString = strConnectionString

dbcon.Open()

 

'cmd = New SqlCommand

 

 

 

 

dbCommand.Connection = dbcon

dbCommand.CommandType = CommandType.Text

dbCommand.CommandText = strSQL

rdr = dbCommand.ExecuteReader()

SqlDataSource1.ConnectionString = strConnectionString

SqlDataSource1.SelectCommand = strSQL

 

RadGrid1.DataSourceID =

"SqlDataSource1"

 

 

 

 

RadGrid1.AllowPaging =

True

 

 

 

 

RadGrid1.AllowSorting =

True

 

 

 

 

RadGrid1.PagerStyle.Mode = GridPagerMode.NextPrevAndNumeric

RadGrid1.MasterTableView.Columns.Add(boundColumn)

boundColumn.DataField = "First Name"

 

 

 

 

boundColumn.HeaderText =

"First Name"

 

 

 

 

 

boundColumn =

New GridBoundColumn()

 

RadGrid1.MasterTableView.Columns.Add(boundColumn)

boundColumn.DataField =

"Last Name"

 

 

 

 

boundColumn.HeaderText =

"Last Name"

 

 

 

 

 

boundColumn =

New GridBoundColumn()

RadGrid1.AutoGenerateColumns =

False

 

 

 

 

 

Dim boundColumn As GridBoundColumn

 

boundColumn =

New GridBoundColumn()

 

 

 

RadGrid1.MasterTableView.Columns.Add(boundColumn)

 

boundColumn.DataField =

"Company"

 

 

 

 

boundColumn.HeaderText =

"Company"

 

 

 

 

 

Dim hyperLinkColumn As GridHyperLinkColumn

 

hyperLinkColumn =

New GridHyperLinkColumn()

 

RadGrid1.MasterTableView.Columns.Add(hyperLinkColumn)

 

Dim dataNavigateUrlFields() As String = {"MyPyle ID"}

 

hyperLinkColumn.DataTextField =

"MyPyle ID"

 

 

 

 

hyperLinkColumn.DataNavigateUrlFields = dataNavigateUrlFields

hyperLinkColumn.HeaderText =

"MyPyle ID"

 

 

 

 

hyperLinkColumn.DataNavigateUrlFormatString =

"../MyPyle/MyPyleLTLTracking.aspx?Pro={0}"

 

 

 

 

 

End If

 

 

 

 

 

 

 

End Sub

 

 

 

  
What am I missing?
Thank you.
Galina

 

0
Pavlina
Telerik team
answered on 01 Jul 2009, 12:32 PM
Hello Galina,

To avoid duplicate posts, we will continue our communication in the other (support ticket) post that you have opened on the matter.
I have already answered your other ticket with the same question.

Regards,
Pavlina
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
kavitha
Top achievements
Rank 1
answered on 13 May 2011, 02:59 PM
Hello,
Where can I find the exemple to add sorting and paging functionality of a radGrid build dynamically.
I have radgrid declared in aspx page. I have added the grid columns dynamically in code behind in OnInit() where I am in creating and
binding the grid everytime after postback.
It works fine till now.
I have added AllowSorting="True" and OnsortCommand . The grid sorts correctly for first time.
But second time it gives following error.
An error has occurred because a control with id 'aaa$gdvaaa$ctl01$ctl02$ctl01$ctl02' could not be located or a different control is assigned to the same ID after postback. If the ID is not assigned, explicitly set the ID property of controls that raise postback events to avoid this error.

How can I sort this dynamic radGrid?
0
Pavlina
Telerik team
answered on 16 May 2011, 05:15 PM
Hi Kavitha,

Are you able to reproduce the issue in a sample page? We will appreciate if you could send it via a support ticket so that we can investigate it locally and provide resolution.

Thank you in advance.

All the best,
Pavlina
the Telerik team

Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

0
kavitha
Top achievements
Rank 1
answered on 19 May 2011, 04:37 PM
In my sample page, I am having simple Radgrid declared in aspx page and columns is added in runtime. In this simple project sorting and paging is working fine.
But in my project where i have declared the same type of radGrid in user Control, they are not working correctily.
In grid paging, all pages other than first page is working correctly.
But when I click first page, the "OnPageIndexChanged" is not fired.
Sorting also has the same problem that i have written in my previous post.
I am using radGrid ASP.NET.(version 5.1)
Do u have any solution?
Thanks.
0
Pavlina
Telerik team
answered on 23 May 2011, 11:18 AM
Hello Kavitha,

This error can occur when the ViewState of the grid gets corrupted across postback. I suggest you check whether your binding logic is correct (reviewing the online demos regarding simple / advanced binding) and that you generate the control structure properly when you define the grid structure dynamically.
http://www.telerik.com/help/aspnet-ajax/grid-programmatic-creation.html

Regards,
Pavlina
the Telerik team

Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

0
kavitha
Top achievements
Rank 1
answered on 23 May 2011, 05:36 PM
Hello pavilina,

The paging and sorting of grid  worked when I made binding using "OnNeedDataSource".
Thanks for the reply
0
Pavlina
Telerik team
answered on 24 May 2011, 08:39 AM
Hello Kavitha,

I am glad to hear that the provided information was useful. Good luck with your project!

Best wishes,
Pavlina
the Telerik team

Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

0
Trusha
Top achievements
Rank 1
answered on 25 Jul 2013, 12:59 PM
The demo application attached in this thread uses AccessDataSource and I am using ObjectDataSource , In my case sorting is working for Parent grid using NeedDataSource but when clicked on sort child grid disappears and only parent grid is shown.
I am using OnDetailTableDataBind, on the post back of sorting "e.DetailTableView.Name" is found null.

protected void ctlGrd_DetailTableDataBind(object source, Telerik.Web.UI.GridDetailTableDataBindEventArgs e)
        {           
            // ASSIGN child datasource.
            switch (e.DetailTableView.Name)
            {
                case "ChildTable":
                    {
                        e.DetailTableView.DataSourceID = "objData";
                        break;
                    }
            }
        }
Please suggest how to resolve this...
0
Trusha
Top achievements
Rank 1
answered on 26 Jul 2013, 09:00 AM
Can someone please help me, this is urgent.
0
Pavlina
Telerik team
answered on 30 Jul 2013, 01:32 PM
Hi Snehal,

In the description section of the following article are the main steps for binding grid instance to hierarchical data source through the DetailTableDataBind event of the control:
http://demos.telerik.com/aspnet-ajax/grid/examples/programming/detailtabledatabind/defaultcs.aspx

Check it out and see if you are missing something out.

Regards,
Pavlina
Telerik
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to the blog feed now.
Tags
Grid
Asked by
Galina Grimberg
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Galina Grimberg
Top achievements
Rank 1
Pavlina
Telerik team
kavitha
Top achievements
Rank 1
Trusha
Top achievements
Rank 1
Share this question
or