Hi,
I am wishing to change the colour of a row if it is 'urgent' in my internal message system.
I found this code...
and changed it to suit my grid, or so I believed; however it does not work properly, and throws an exception ("Object reference not set to an instance of an object.") when checking whether
"If Urgent.Checked = true then"
What am I doing wrong, the code for my radgrid is...
and it comes from a sql database
Thanks in advance
Ryan
I am wishing to change the colour of a row if it is 'urgent' in my internal message system.
I found this code...
Protected
Sub
RadGrid1_ItemDataBound(
ByVal
sender
As
System.
Object
,
ByVal
e
As
Telerik.Web.UI.GridItemEventArgs)
Handles
RadGrid1.ItemDataBound
'Change the color of inactive rows
If
TypeOf
e.Item
Is
GridDataItem
Then
Dim
item
As
GridDataItem =
DirectCast
(e.Item, GridDataItem)
Dim
Urgent
As
CheckBox =
DirectCast
(item.FindControl(
"Urgent"
), CheckBox)
If
Urgent.Checked =
True
Then
e.Item.BackColor = Drawing.Color.RoyalBlue
End
If
End
If
End
Sub
and changed it to suit my grid, or so I believed; however it does not work properly, and throws an exception ("Object reference not set to an instance of an object.") when checking whether
"If Urgent.Checked = true then"
What am I doing wrong, the code for my radgrid is...
<telerik:RadGrid ID=
"RadGrid1"
runat=
"server"
AutoGenerateSelectColumn=
"True"
CellSpacing=
"0"
GridLines=
"Horizontal"
AutoGenerateColumns=
"False"
OnSelectedIndexChanged=
"RadGrid1_SelectedIndexChanged"
OnNeedDataSource=
"RadGrid1_NeedDataSource"
AllowAutomaticUpdates=
"True"
AllowPaging=
"True"
AllowSorting=
"True"
ToolTip=
"Click on a message to view it"
>
<SortingSettings EnableSkinSortStyles=
"false"
/>
<ClientSettings EnablePostBackOnRowClick=
"true"
EnableRowHoverStyle=
"True"
>
<Selecting AllowRowSelect=
"true"
/>
</ClientSettings>
<MasterTableView DataKeyNames=
"UniqueID"
PageSize=
"20"
Width=
"100%"
>
<Columns>
<telerik:GridBoundColumn DataField=
"UniqueID"
HeaderText=
"UniqueID"
UniqueName=
"UniqueID"
FooterStyle-Width=
"1px"
HeaderStyle-Width=
"1px"
ItemStyle-Width=
"1px"
Visible=
"false"
DataType=
"System.Int32"
ReadOnly
=
"True"
SortExpression=
"UniqueID"
>
<FooterStyle Width=
"1px"
></FooterStyle>
<HeaderStyle Width=
"1px"
></HeaderStyle>
<ItemStyle Width=
"1px"
></ItemStyle>
</telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField=
"Customer"
HeaderText=
"Customer"
UniqueName=
"Customer"
FooterStyle-Width=
"14%"
HeaderStyle-Width=
"14%"
ItemStyle-Width=
"14%"
FilterControlAltText=
"Filter Customer column"
SortExpression=
"Customer"
>
<FooterStyle Width=
"14%"
></FooterStyle>
<HeaderStyle Width=
"14%"
></HeaderStyle>
<ItemStyle Width=
"14%"
></ItemStyle>
</telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField=
"Subject"
HeaderText=
"Subject"
UniqueName=
"Subject"
FooterStyle-Width=
"46%"
HeaderStyle-Width=
"46%"
ItemStyle-Width=
"46%"
SortExpression=
"Subject"
>
<FooterStyle Width=
"46%"
></FooterStyle>
<HeaderStyle Width=
"46%"
></HeaderStyle>
<ItemStyle Width=
"46%"
></ItemStyle>
</telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField=
"Name"
HeaderText=
"Taken By"
UniqueName=
"Name"
FooterStyle-Width=
"8%"
HeaderStyle-Width=
"8%"
ItemStyle-Width=
"8%"
DataType=
"System.Int32"
FilterControlAltText=
"Filter TakenByID column"
SortExpression=
"TakenByID"
>
<FooterStyle Width=
"8%"
></FooterStyle>
<HeaderStyle Width=
"8%"
></HeaderStyle>
<ItemStyle Width=
"8%"
></ItemStyle>
</telerik:GridBoundColumn>
<telerik:GridBoundColumn DataField=
"TakenOn"
HeaderText=
"TakenOn"
UniqueName=
"TakenOn"
FooterStyle-Width=
"11%"
HeaderStyle-Width=
"11%"
ItemStyle-Width=
"11%"
DataType=
"System.DateTime"
FilterControlAltText=
"Filter TakenOn column"
SortExpression=
"TakenOn"
>
<FooterStyle Width=
"11%"
></FooterStyle>
<HeaderStyle Width=
"11%"
></HeaderStyle>
<ItemStyle Width=
"11%"
></ItemStyle>
</telerik:GridBoundColumn>
<telerik:GridCheckBoxColumn DataField=
"Urgent"
DataType=
"System.Boolean"
FilterControlAltText=
"Filter Urgent column"
HeaderText=
"Urgent"
SortExpression=
"Urgent"
UniqueName=
"Urgent"
FooterStyle-Width=
"7%"
HeaderStyle-Width=
"7%"
ItemStyle-Width=
"7%"
>
<FooterStyle Width=
"7%"
></FooterStyle>
<HeaderStyle Width=
"7%"
></HeaderStyle>
<ItemStyle Width=
"7%"
></ItemStyle>
</telerik:GridCheckBoxColumn>
<telerik:GridBoundColumn DataField=
"StatusNew"
HeaderText=
"Status ID"
UniqueName=
"StatusNew"
FooterStyle-Width=
"11%"
HeaderStyle-Width=
"11%"
ItemStyle-Width=
"11%"
SortExpression=
"StatusID"
>
<FooterStyle Width=
"11%"
></FooterStyle>
<HeaderStyle Width=
"11%"
></HeaderStyle>
<ItemStyle Width=
"11%"
></ItemStyle>
</telerik:GridBoundColumn>
<telerik:GridButtonColumn CommandName=
"Delete"
Text=
"Delete"
UniqueName=
"DeleteColumn"
HeaderText=
"Delete"
ButtonType=
"ImageButton"
ImageUrl=
"~/RadControls/Grid/Skins/Default/Delete.gif"
FooterStyle-Width=
"4%"
HeaderStyle-Width=
"4%"
ItemStyle-Width=
"4%"
>
<FooterStyle Width=
"4%"
></FooterStyle>
<HeaderStyle Width=
"4%"
></HeaderStyle>
<ItemStyle Width=
"4%"
></ItemStyle>
</telerik:GridButtonColumn>
</Columns>
<CommandItemSettings ExportToPdfText=
"Export to PDF"
></CommandItemSettings>
<RowIndicatorColumn Visible=
"True"
FilterControlAltText=
"Filter RowIndicator column"
>
<HeaderStyle Width=
"5px"
></HeaderStyle>
</RowIndicatorColumn>
<ExpandCollapseColumn Visible=
"True"
FilterControlAltText=
"Filter ExpandColumn column"
>
<HeaderStyle Width=
"5px"
></HeaderStyle>
</ExpandCollapseColumn>
<EditFormSettings>
<EditColumn FilterControlAltText=
"Filter EditCommandColumn column"
>
</EditColumn>
</EditFormSettings>
</MasterTableView>
<FilterMenu EnableImageSprites=
"False"
>
</FilterMenu>
</telerik:RadGrid>
and it comes from a sql database
Thanks in advance
Ryan