5 Answers, 1 is accepted

If you want to access the value in ItemDataBound event, then you can directly access the value using DataRowView object.
C#:
protected
void
RadGrid1_ItemDataBound(
object
sender, GridItemEventArgs e)
{
if
(e.Item
is
GridDataItem)
{
DataRowView groupDataRow = (DataRowView)e.Item.DataItem;
string
value = groupDataRow[
"money"
].ToString();
}
}
In the case of any other event, format the string by removing the '$' symbol from code behind which is shown below.
ASPX:
<
telerik:GridBoundColumn
DataField
=
"money"
DataFormatString
=
"{0:C}"
UniqueName
=
"money"
>
</
telerik:GridBoundColumn
>
C#:
string
v = item[
"money"
].Text;
v = v.Split(
'$'
)[1];
Thanks,
Princy.

You could get the 'raw' values from the original data source object from the e.Item.DataItem. DataItem property keeps the original object to which the RadGrid's row is bound. The values into this object are not formatted yet (by DataFormatString property).
However if you want to get the formatted value not the original(for example in your case 10 is the original value $10.00 is the formatted value) you could get it directly from the cell text:
string
formattedText =(e.Item
as
GridDataItem)[
"ColumnUniqueName"
].Text
Additionally you could get the original values on every event which occurs after ItemDataBound for example on RadGrid.PreRender:
void
RadGrid1_PreRender(
object
sender, EventArgs e)
{
object
o = RadGrid1.MasterTableView.Items[0].DataItem;
}
I hope this helps.
All the best,
Radoslav
the Telerik team
Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.

This is my code. In this at page load in grid lblCrDr
color should get changed but color is not getting changed so I want solution for this please help me.
if (e.Item is GridDataItem)
{
GridDataItem item = e.Item as GridDataItem;
double Balance;
double CumBalance;
double.TryParse(item["Balance"].Text, out Balance);
double.TryParse(item["CumBalance"].Text, out CumBalance);
Label lblCrDr = new Label();
if (Balance >= 0)
{
lblCrDr.Text = " (Dr)";
item["Balance"].Text = item["Balance"].Text + lblCrDr.Text;
lblCrDr.ForeColor = System.Drawing.Color.Gray;
}
else
{
lblCrDr.Text = " (Cr)";
item["Balance"].Text = item["Balance"].Text + lblCrDr.Text;
lblCrDr.ForeColor = System.Drawing.Color.Red;
}
if (CumBalance >= 0)
{
lblCrDr.Text = " (Dr)";
item["CumBalance"].Text = item["CumBalance"].Text + lblCrDr.Text;
lblCrDr.ForeColor = System.Drawing.Color.Gray;
}
else
{
lblCrDr.Text = " (Cr)";
item["CumBalance"].Text = item["CumBalance"].Text + lblCrDr.Text;
lblCrDr.ForeColor = System.Drawing.Color.Red;
}

Try accessing the label as shown below.
C#:
void
RadGrid1_ItemDataBound(
object
sender, GridItemEventArgs e)
{
if
(e.Item
is
GridDataItem)
{
GridDataItem item = e.Item
as
GridDataItem;
Label lbl = (Label)item.FindControl(
"Label1"
);
}
}
Thanks,
Shinu