Hello
My Grid
<telerik:RadGrid RenderMode=
"Lightweight"
ID=
"catGrid"
Width=
"944"
AllowPaging=
"false"
runat=
"server"
GridLines=
"None"
Skin=
"Office2010Blue"
AllowSorting=
"false"
AutoGenerateColumns=
"False"
OnNeedDataSource=
"CatGridNeedDataSource"
ShowFooter=
"false"
ShowStatusBar=
"false"
OnItemCommand=
"CatGridItemCommand"
OnItemDataBound=
"CatGridItemDataBound"
>
<MasterTableView DataKeyNames=
"ID"
ClientDataKeyNames=
"ID"
>
<Columns>
<telerik:GridCalculatedColumn DataFields=
"TestName, TestNameDetail"
Expression=
"{0}+{1}"
HeaderText=
"TEST NAME"
>
</telerik:GridCalculatedColumn>
<telerik:GridCalculatedColumn DataFields=
"Standard, StandardDetail"
Expression=
"{0}+{1}"
HeaderText=
"STANDARD"
>
</telerik:GridCalculatedColumn>
<telerik:GridBoundColumn DataField=
"Pricing"
HeaderText=
"PRICING"
DataFormatString=
"{0:c}"
HtmlEncode=
"false"
ItemStyle-HorizontalAlign=
"right"
>
</telerik:GridBoundColumn>
<telerik:GridTemplateColumn HeaderText=
"DETAIL"
UniqueName=
"DETAIL"
>
<ItemTemplate>
<telerik:RadImageButton ID=
"detailBtn"
runat=
"server"
Image-Url=
"~/App_Themes/Site/Core/DetailIcon.png"
Width=
"32"
Height=
"32"
CommandName=
"Detail"
CommandArgument=
'<%#Eval("CategoryID") +","+ Eval("Details")%>'
></telerik:RadImageButton>
</ItemTemplate>
</telerik:GridTemplateColumn>
<telerik:GridTemplateColumn HeaderText=
"REPORT"
UniqueName=
"REPORT"
>
<ItemTemplate>
<telerik:RadImageButton ID=
"ReportBtn"
runat=
"server"
Image-Url=
"~/App_Themes/Site/Core/Reporticon.png"
Width=
"32"
Height=
"32"
CommandName=
"Report"
Value=
"ID"
></telerik:RadImageButton>
</ItemTemplate>
</telerik:GridTemplateColumn>
</Columns>
</MasterTableView>
<ClientSettings EnableRowHoverStyle=
"true"
>
</ClientSettings>
</telerik:RadGrid>
My Code Behind
protected
void
CatGridItemDataBound(
object
sender, GridItemEventArgs e)
{
//Is it a GridDataItem
if
(e.Item
is
GridDataItem)
{
var oRow = (DataRowView) e.Item.DataItem;
var detr = (RadImageButton) oRow[
"DETAIL"
];
string
detailTF = (detr).CommandArgument.ToString();
var arg =
new
string
[2];
char
[] splitter = {
','
};
arg = detailTF.Split(splitter);
HasDetail = Convert.ToBoolean(arg);
if
(HasDetail ==
true
)
{
catGrid.MasterTableView.GetColumn(columnUniqueName:
"DETAIL"
).Display =
true
;
}
else
{
catGrid.MasterTableView.GetColumn(columnUniqueName:
"DETAIL"
).Display =
false
;
}
}
}
I am trying to get the second CommandArgument value which is true or false of the ImageButton. Once I have that value if false I want to set that row item to display.false. Currently I am receiving an error:
Unable to cast object of type 'DynamicClass1' to type 'System.Data.DataRowView'.
How can I achieve my goal?