Deep Ghosh
Top achievements
Rank 1
Deep Ghosh
asked on 13 Aug 2012, 05:47 PM
I have a Page which has a HEADER section. Once information is filled up, I want to display a Grid control on the bottom half of a page.
How do I achieve this in ASP.NET AJAX.
The Grid Control contains Combo Boxes and Check Boxes.
How do I achieve this in ASP.NET AJAX.
The Grid Control contains Combo Boxes and Check Boxes.
4 Answers, 1 is accepted
0
Shinu
Top achievements
Rank 2
answered on 14 Aug 2012, 05:37 AM
Hi Deep,
You can add a RadGrid dynamically as shown below.
C#:
Also check the following help documentation which explains more about this.
Programmatic Creation.
Thanks,
Shinu.
You can add a RadGrid dynamically as shown below.
C#:
protected
void
Page_Init(
object
sender, System.EventArgs e)
{
RadGrid1 =
new
RadGrid();
RadGrid1.ID =
"RadGrid1"
;
PlaceHolder1.Controls.Add(RadGrid1);
RadGrid1.MasterTableView.DataKeyNames =
new
string
[] {
"EmployeeID"
};
RadGrid1.MasterTableView.AutoGenerateColumns =
false
;
GridBoundColumn boundColumn;
boundColumn =
new
GridBoundColumn();
NewTemplateColumn templateColumn =
new
NewTemplateColumn();
templateColumn.ItemTemplate =
new
TemplateColumn();
RadGrid1.MasterTableView.Columns.Add(templateColumn);
GridBoundColumn boundColumn1 =
new
GridBoundColumn();
boundColumn1.DataField =
"ContactName"
;
boundColumn1.UniqueName =
"ConactName"
;
boundColumn1.HeaderText =
"Bound Column"
;
RadGrid1.MasterTableView.Columns.Add(boundColumn);
boundColumn.DataField =
"EmployeeID"
;
boundColumn.HeaderText =
"EmployeeID"
;
boundColumn.DataType =
typeof
(System.Decimal);
boundColumn =
new
GridBoundColumn();
RadGrid1.MasterTableView.Columns.Add(boundColumn);
}
public
partial
class
TemplateColumn : ITemplate
//adding template fields
{
public
void
InstantiateIn(Control container)
{
CheckBox chk =
new
CheckBox();
chk.ID =
"CheckBox1"
;
container.Controls.Add(chk);
}
}
Programmatic Creation.
Thanks,
Shinu.
0
Deep Ghosh
Top achievements
Rank 1
answered on 16 Aug 2012, 11:28 PM
Hello,
That code is fine to add on Page_INIT.
We already have some controls on the screen.
Then when user presses a button, We want to add the grid. Attached is a sample of such screen. Top part is the initial display. Bottom part needs to be added dynamically.
Please help us on how to do this.
That code is fine to add on Page_INIT.
We already have some controls on the screen.
Then when user presses a button, We want to add the grid. Attached is a sample of such screen. Top part is the initial display. Bottom part needs to be added dynamically.
Please help us on how to do this.
0
Shinu
Top achievements
Rank 2
answered on 17 Aug 2012, 07:38 AM
Hi,
You can add a div and style it accordingly to show the grid at the bottom.
aspx:
C#:
Thanks,
Shinu.
You can add a div and style it accordingly to show the grid at the bottom.
aspx:
<
div
id
=
"div1"
runat
=
"server"
style
=
"margin-top:500px"
>
</
div
>
div1.Controls.Add(RadGrid1);
Thanks,
Shinu.
0
Deep Ghosh
Top achievements
Rank 1
answered on 07 Sep 2012, 07:52 PM
Hi Shinu,
Thanks for earlier reply.
Basically we want to generate the grid dynamically and add to the page on some action such as button click with no page refresh.
- a aspx page with RadGird is called and the output is sent back through web method and displayed. This is displaying the radgrid but the add record and column re-oriding throws error due to corruption in viewstate.
Another option we tried is - a dynamic grid is being created and then using rendercontrol method trying to get the html.
The html code is genereated but only a black box is appearing and not the grid.( Radgrid is added to a panel and panel is added to a page and panel.RenderControl is being done).
- Please let us know which method to use and how to resolve the issue in each approach or is there any other apporach.
I can provide a sample code . Please let me know your email id.
Regards,
Deep
Thanks for earlier reply.
Basically we want to generate the grid dynamically and add to the page on some action such as button click with no page refresh.
- a aspx page with RadGird is called and the output is sent back through web method and displayed. This is displaying the radgrid but the add record and column re-oriding throws error due to corruption in viewstate.
Another option we tried is - a dynamic grid is being created and then using rendercontrol method trying to get the html.
The html code is genereated but only a black box is appearing and not the grid.( Radgrid is added to a panel and panel is added to a page and panel.RenderControl is being done).
- Please let us know which method to use and how to resolve the issue in each approach or is there any other apporach.
I can provide a sample code . Please let me know your email id.
Regards,
Deep