6 Answers, 1 is accepted
0

Princy
Top achievements
Rank 2
answered on 16 May 2014, 05:30 AM
Hi Tamim,
You can refer the following articles which will give you the required information.
Creating a RadGrid Programmatically
Advanced Data-binding (Using NeedDataSource Event)
Thanks,
Princy
You can refer the following articles which will give you the required information.
Creating a RadGrid Programmatically
Advanced Data-binding (Using NeedDataSource Event)
Thanks,
Princy
0

Tamim
Top achievements
Rank 1
answered on 16 May 2014, 05:51 AM
Thanks princy for ur reply..
One more question is there...
Dynamic create Button(Expand and collapse) function how to working...
See my screen shot..
1) I want first each Project assign to tab(bar) default collapse when i click Expand button to view MY PROGRESS CLAIM (2), MY PAYMENT CERTIFICATE (1)...
2) In MY PROGRESS CLAIM i click Prepare to set Link.
Thanks,
Ansari.
One more question is there...
Dynamic create Button(Expand and collapse) function how to working...
See my screen shot..
1) I want first each Project assign to tab(bar) default collapse when i click Expand button to view MY PROGRESS CLAIM (2), MY PAYMENT CERTIFICATE (1)...
2) In MY PROGRESS CLAIM i click Prepare to set Link.
Thanks,
Ansari.
0

Princy
Top achievements
Rank 2
answered on 19 May 2014, 05:09 AM
Hi Tamim,
From your screenshot I guess you can use grouping. Please try the following code snippet. Elaborate on your requirement if this doesn't help.
C#:
Thanks,
Princy
From your screenshot I guess you can use grouping. Please try the following code snippet. Elaborate on your requirement if this doesn't help.
C#:
//Group Expression dynamically
RadGrid1.MasterTableView.GroupsDefaultExpanded =
false
;
GridGroupByExpression expression =
new
GridGroupByExpression();
GridGroupByField gridGroupByField =
new
GridGroupByField();
gridGroupByField =
new
GridGroupByField();
gridGroupByField.FieldName =
"ShipCountry"
;
gridGroupByField.HeaderText =
"ShipCountry"
;
gridGroupByField.HeaderValueSeparator =
":"
;
gridGroupByField.FormatString =
" "
;
expression.SelectFields.Add(gridGroupByField);
gridGroupByField.FieldName =
"ShipCountry"
;
expression.GroupByFields.Add(gridGroupByField);
RadGrid1.MasterTableView.GroupByExpressions.Add(expression);
//To display the total count of childitems on header
void
RadGrid1_PreRender(
object
sender, EventArgs e)
{
foreach
(GridGroupHeaderItem groupHeaderItem
in
RadGrid1.MasterTableView.GetItems(GridItemType.GroupHeader))
{
if
(!(groupHeaderItem.DataCell.Text.Contains(
"Child Items:"
)))
{
groupHeaderItem.DataCell.Text = groupHeaderItem.DataCell.Text +
" Child Items: "
+ groupHeaderItem.GetChildItems().Length.ToString();
}
}
}
Thanks,
Princy
0
0

Tamim
Top achievements
Rank 1
answered on 19 May 2014, 10:42 AM
Hi Prince any Examples.....
0

Princy
Top achievements
Rank 2
answered on 20 May 2014, 05:53 AM
Hi Tamim,
From your screenshot I guess you want to use a Hierarchy RadGrid. Please check the below is a sample code snippet and the attached screenshot.
ASPX:
C#:
Thanks,
Princy
From your screenshot I guess you want to use a Hierarchy RadGrid. Please check the below is a sample code snippet and the attached screenshot.
ASPX:
<
telerik:RadGrid
ID
=
"RadGrid1"
runat
=
"server"
AutoGenerateColumns
=
"False"
OnDetailTableDataBind
=
"RadGrid1_DetailTableDataBind"
OnNeedDataSource
=
"RadGrid1_NeedDataSource"
>
<
MasterTableView
DataKeyNames
=
"CountryID"
HierarchyLoadMode
=
"ServerBind"
Name
=
"Country"
>
<
DetailTables
>
<
telerik:GridTableView
DataKeyNames
=
"StateID"
Name
=
"State"
>
<
DetailTables
>
<
telerik:GridTableView
DataKeyNames
=
"StateID"
Name
=
"District"
>
<
Columns
>
<
telerik:GridBoundColumn
HeaderText
=
"DistrictID"
DataField
=
"DistrictID"
UniqueName
=
"DistrictID"
>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
HeaderText
=
"DistrictName"
DataField
=
"DistrictName"
UniqueName
=
"DistrictName"
>
</
telerik:GridBoundColumn
>
</
Columns
>
</
telerik:GridTableView
>
</
DetailTables
>
<
Columns
>
<
telerik:GridBoundColumn
HeaderText
=
"StateID"
DataField
=
"StateID"
UniqueName
=
"StateID"
>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
HeaderText
=
"StateName"
DataField
=
"StateName"
UniqueName
=
"StateName"
>
</
telerik:GridBoundColumn
>
</
Columns
>
</
telerik:GridTableView
>
</
DetailTables
>
<
Columns
>
<
telerik:GridBoundColumn
SortExpression
=
"CountryID"
HeaderText
=
"CountryID"
DataField
=
"CountryID"
>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
SortExpression
=
"CountryName"
HeaderText
=
"CountryName"
DataField
=
"CountryName"
>
</
telerik:GridBoundColumn
>
</
Columns
>
</
MasterTableView
>
</
telerik:RadGrid
>
C#:
protected
void
RadGrid1_NeedDataSource(
object
source, Telerik.Web.UI.GridNeedDataSourceEventArgs e)
{
if
(!e.IsFromDetailTable)
{
RadGrid1.DataSource = GetDataTable(
"Select * from Country"
);
}
}
protected
void
RadGrid1_DetailTableDataBind(
object
source, Telerik.Web.UI.GridDetailTableDataBindEventArgs e)
{
GridDataItem dataItem = (GridDataItem)e.DetailTableView.ParentItem;
switch
(e.DetailTableView.Name)
{
case
"State"
:
{
string
CountryID = dataItem.GetDataKeyValue(
"CountryID"
).ToString();
e.DetailTableView.DataSource = GetDataTable(
"SELECT * FROM State WHERE CountryID = '"
+ CountryID +
"'"
);
break
;
}
case
"District"
:
{
string
StateID = dataItem.GetDataKeyValue(
"StateID"
).ToString();
e.DetailTableView.DataSource = GetDataTable(
"SELECT * FROM District WHERE StateID = '"
+ StateID +
"'"
);
break
;
}
}
}
public
DataTable GetDataTable(
string
query)
{
String ConnString = ConfigurationManager.ConnectionStrings[
"ConnectionString"
].ConnectionString;
SqlConnection conn =
new
SqlConnection(ConnString);
SqlDataAdapter adapter =
new
SqlDataAdapter();
adapter.SelectCommand =
new
SqlCommand(query, conn);
DataTable myDataTable =
new
DataTable();
conn.Open();
try
{
adapter.Fill(myDataTable);
}
finally
{
conn.Close();
}
return
myDataTable;
}
Thanks,
Princy