Hi
I have a mail table in DB. There is the IsReaded field in mail table (0=readed, 1 = unreaded)
I select some records (with IsReaded field) and bound it to the RadGrid. But I want bold the rows which its IsReaded field is 1.
May anyone help me, how and in which event can I fix it?
Best regards. Morteza
4 Answers, 1 is accepted
0
Cori
Top achievements
Rank 2
answered on 20 Aug 2010, 08:31 PM
You handle it in the ItemDataBound event. There you can check if the row being bound has isReaded = 1 and then change the ItemStyle.FontBold="true" to bold the text.
I hope that helps.
I hope that helps.
0
Cori
Top achievements
Rank 2
answered on 20 Aug 2010, 08:37 PM
Here's the code to do it. Forgot to include it in previous post.
I don't know if your isReaded column is an int or bit, so you can change the casting and condition accordingly. Also, make sure you have isReaded in the DataKeyValues list.
protected
void
RadGrid_ItemDataBound(
object
sender, GridItemEventArgs e)
{
if
(e.Item
is
GridDataItem)
{
GridDataItem grdItem = (GridDataItem)e.Item;
if
((
int
)grdItem.GetDataKeyValue(
"isReaded"
) == 1)
{
grdItem.Font.Bold =
true
;
}
}
}
I don't know if your isReaded column is an int or bit, so you can change the casting and condition accordingly. Also, make sure you have isReaded in the DataKeyValues list.
0
morteza
Top achievements
Rank 1
answered on 20 Aug 2010, 11:28 PM
Thanks a lot for replying.
I did this before. but " grditem.GetDataKeyValue("isReaded") " returns null . may u explain more about DataKeyValues list, please.
morteza.
I did this before. but " grditem.GetDataKeyValue("isReaded") " returns null . may u explain more about DataKeyValues list, please.
morteza.
0
Princy
Top achievements
Rank 2
answered on 26 Aug 2010, 09:36 AM
Hello Morteza,
Have you set the the data-field 'isReaded' in the DataKeyNames property of MasterTableView like below?
ASPX:
Or you can directly access the cell value using ColumnUniqueName.
C#:
Thanks,
Princy.
Have you set the the data-field 'isReaded' in the DataKeyNames property of MasterTableView like below?
ASPX:
<
MasterTableView
DataKeyNames
=
"isReaded"
. . . . . . >
Or you can directly access the cell value using ColumnUniqueName.
C#:
protected
void
RadGrid_ItemDataBound(
object
sender, GridItemEventArgs e)
{
if
(e.Item
is
GridDataItem)
{
GridDataItem grdItem = (GridDataItem)e.Item;
if
(grdItem[
"isReaded"
].Text ==
"1"
)
{
grdItem.Font.Bold =
true
;
}
}
}
Thanks,
Princy.