asp.net - Is there a way to use Telerik radgrid's export to excel on datatable in codebehind -
i trying export datatable excel on asp.net machine without office interop, since i'm using telerik asp.net, there way use radgrid's export excel function on datatable in code behind @ runtime without creating design radgrid in page?
please try below code snippet.
protected void page_load(object sender, system.eventargs e) { radgrid1 = new radgrid(); radgrid1.id = "radgrid1"; radgrid1.needdatasource += new gridneeddatasourceeventhandler(radgrid1_needdatasource); } protected void radgrid1_needdatasource(object sender, gridneeddatasourceeventargs e) { datatable dt = new datatable(); dt.columns.add("shipper", typeof(string)); dt.columns.add("shippertemp", typeof(string)); dt.rows.add("cshipper1", "1"); dt.rows.add("bshipper2", "2"); dt.rows.add("ashipper1", "1"); dt.rows.add("eshipper1", "2"); dt.rows.add("dshipper4", "4"); (sender radgrid).datasource = dt; } protected void button1_click(object sender, eventargs e) { radgrid1.rebind(); page.controls.add(radgrid1); // not add control in page radgrid1.mastertableview.exporttoexcel(); }
Comments
Post a Comment