or
<
telerik:RadGrid
ID
=
"grdResults"
Height
=
"100%"
runat
=
"server"
OnNeedDataSource
=
"grdResults_NeedDataSource"
OnItemDataBound
=
"grdResults_ItemDataBound"
GridLines
=
"None"
AllowSorting
=
"true"
AllowPaging
=
"false"
AutoGenerateColumns
=
"false"
>
<
ClientSettings
>
<
Scrolling
AllowScroll
=
"true"
UseStaticHeaders
=
"true"
SaveScrollPosition
=
"false"
/>
<
Selecting
AllowRowSelect
=
"true"
/>
</
ClientSettings
>
<
MasterTableView
>
<
Columns
>
<
telerik:GridBoundColumn
HeaderText
=
"StatusCodeDescription"
UniqueName
=
"StatusCodeDescription"
DataField
=
"StatusCodeDescription"
HeaderStyle-Width
=
"8%"
></
telerik:GridBoundColumn
>
</
Columns
>
</
MasterTableView
>
</
telerik:RadGrid
>
then dynamically add a column in the page load like:
if
(!Page.IsPostBack)
{
var boundColumn =
new
GridBoundColumn();
e.GridColumns.Add(boundColumn);
boundColumn.HeaderText =
"Select"
;
boundColumn.DataField =
"Id"
;
boundColumn.UniqueName =
"selectId"
;
}
and still use the ItemDataBound event to manipulate the dynamically added column?
I can retrieve and manipulate the statically defined column, but I am unable to do the same for the
dynamically added column?
What am I doing wrong?
private
void
GridItemDataBound(
object
sender, GridItemEventArgs e)
{
if
(e.Item
is
GridDataItem)
{
var item = (GridDataItem)e.Item;
item[
"selectId"
].Text =
"test"
;
if
(item[
"StatusCodeDescription"
].Text.Length > 5)
item[
"StatusCodeDescription"
].Text = item[
"StatusCodeDescription"
].Text.Substring(0, 2) +
"..."
;
}
}
Thanks a lot!!
Regards
protected
void
RadGrid1_ItemCreated(
object
sender, GridItemEventArgs e)
{
if
(e.Item
is
GridEditableItem && e.Item.IsInEditMode)
{
GridEditableItem editedItem = e.Item
as
GridEditableItem;
GridHTMLEditorColumnEditor editor = (GridHTMLEditorColumnEditor) editedItem.EditManager.GetColumnEditor(colName);
editor.Editor.Width = Unit.Pixel(750);
[...]
protected void RadGrid1_itemDataBound(object sender, GridItemEventArgs e)
{
if (e.Item is GridDataItem)
{
RadGrid RadGrid_DetailsHeader = (RadGrid)e.Item.FindControl("RadGrid_DetailsHeader");
RadGrid_DetailsHeaderBind(casRepHeader, RadGrid_DetailsHeader);
}
}