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

how to add data to radgrid with out any database use

1 Answer 453 Views
Grid
This is a migrated thread and some comments may be shown as answers.
pradeep kumar
Top achievements
Rank 1
pradeep kumar asked on 01 Apr 2010, 09:14 AM
i have telerik rad grid control i want to display radgrid on pageload with some data in which i have to add data to rad grid in designing only no connection with database.how to add data to radgrid and it has to display in my pageload itself

1 Answer, 1 is accepted

Sort by
0
Schlurk
Top achievements
Rank 2
answered on 01 Apr 2010, 04:12 PM
What you could do is create a DataTable and bind that to the RadGrid during the PageLoad event. This doesn't bind the RadGrid to a database, but it still has data bound to it. This is just a quick example but it'll let you have "dummy" data in your RadGrid:

    protected void Page_Load(object sender, EventArgs e) 
    { 
        if (!IsPostBack) 
        { 
            RadGrid1.DataSource = createDataTable(); 
        } 
    } 
 
    private DataTable createDataTable() 
    { 
        DataTable dt = new DataTable(); 
        dt.Columns.Add("Column1"); 
        dt.Columns.Add("Column2"); 
        DataRow dr = dt.NewRow(); 
        dr["Column1"] = "Column1 - Row 1"
        dr["Column2"] = "Column2 - Row 1"
        dt.Rows.Add(dr); 
 
        return dt; 
    } 

Tags
Grid
Asked by
pradeep kumar
Top achievements
Rank 1
Answers by
Schlurk
Top achievements
Rank 2
Share this question
or