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

add grid on the server side

9 Answers 38 Views
Grid
This is a migrated thread and some comments may be shown as answers.
appdev
Top achievements
Rank 1
appdev asked on 28 Oct 2008, 10:20 AM
can i add a grid on the server side? let say i want to display the number of grids base on my records count from the database? thanks.

9 Answers, 1 is accepted

Sort by
0
Daniel
Telerik team
answered on 28 Oct 2008, 10:42 AM
Hello Duy,

A possible approach is shown below:
<asp:PlaceHolder ID="PlaceHolder1" runat="server"></asp:PlaceHolder> 

    protected void Page_Init(object sender, EventArgs e) 
    { 
        RadGrid radGrid = new RadGrid(); 
        for (int i = 1; i < 4; i++) 
        { 
            radGrid = new RadGrid(); 
            radGrid.ID = "radGrid" + i; 
            PlaceHolder1.Controls.Add(radGrid); 
            radGrid.AutoGenerateColumns = true
            radGrid.DataSource = SqlDataSource1;  //replace with the appropriate code
        } 
    } 

RadGrid Programmatic creation
RadGrid Programmatic creation - On PageInit demo
RadGrid Programmatic creation - On PageLoad demo


Greetings,
Daniel
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
appdev
Top achievements
Rank 1
answered on 28 Oct 2008, 10:55 AM
should there be anything in the PlaceHolder1?
0
Daniel
Telerik team
answered on 28 Oct 2008, 11:08 AM
Hello Duy,

The placeholder was used to hold the dynamically created controls. Please examine the provided C# code.

Regards,
Daniel
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
appdev
Top achievements
Rank 1
answered on 29 Oct 2008, 03:45 PM
i get an error saying that i dont have enough memroy. this is not true because with the same amount of data i could get it when i hardcode the grid. could you help me please. thanks

this is the message
'System.OutOfMemoryException' was thrown.
0
Daniel
Telerik team
answered on 29 Oct 2008, 04:00 PM
Hello Duy,

Please give us more details on your project. It would be helpful if you share your code with us - you can attach it to a format support ticket for example.

Regards,
Daniel
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
appdev
Top achievements
Rank 1
answered on 29 Oct 2008, 04:31 PM
nothing special really but here it is
the below code is in class function

 

Public Function SectionReport(ByVal row_id As Integer, ByVal strName As String, ByVal strAddress As String)

 

SQLConnection.Close()

SQLConnection.Open()

 

Dim errmsg As String = ""

 

 

Dim rs As SqlDataReader

 

 

Dim objcmd As New SqlCommand("saStudent", SQLConnection)

 

objcmd.CommandType = CommandType.StoredProcedure

objcmd.Parameters.AddWithValue(

"@row_id", row_id)

 

objcmd.Parameters.AddWithValue(

"@strName", 1)

 

objcmd.Parameters.AddWithValue(

"@strAddress", Address)

 

 

Try

 

rs = objcmd.ExecuteReader()

 

Catch ex As Exception

 

errmsg = ex.Message

 

End Try

 

 

return rs

 

SQLConnection.Close()

rs.Close()

 

End Function

the code below is in default.aspx.vb
page load

 

 

 

 

Dim

radGrid As RadGrid = New RadGrid

 

 

Dim rsSectionReport As SqlDataReader = AllFunctions.SectionReport(CInt(Request.QueryString("rowid").ToString), CStr(strName), strAddress)

 

 

Dim dtSection As Data.DataTable = New Data.DataTable

 

PlaceHolder1.Controls.Add(radGrid)

 

radGrid.DataSource = dtSection

 

 

 

radGrid.DataBind()


this will work fine if i replace radgrid with the regular gridview from microsoft.

 

0
appdev
Top achievements
Rank 1
answered on 29 Oct 2008, 07:03 PM
with a smaller set of data, this will work. so is there away to do this with a huge set of data i really need your help thank you very much.
0
appdev
Top achievements
Rank 1
answered on 29 Oct 2008, 09:17 PM
also how do you export to excel using this approach?
0
Daniel
Telerik team
answered on 31 Oct 2008, 03:20 PM
Hello Duy,

Please test the attached example.

Additionally I would like to suggest you examine our demo with 1,000,000 records.
Boosting Performance with LINQ

Regards,
Daniel
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Tags
Grid
Asked by
appdev
Top achievements
Rank 1
Answers by
Daniel
Telerik team
appdev
Top achievements
Rank 1
Share this question
or