Hello,
I have a radgrid with a template column which has a label that has its text set during the itemDatabound Event. How can I filter on this column?
I have a radgrid with a template column which has a label that has its text set during the itemDatabound Event. How can I filter on this column?
protected
void
rgCompany_ItemDataBound(
object
sender, GridItemEventArgs e)
{
if
(e.Item
is
GridDataItem)
{
Label contactName = e.Item.FindControl(
"Label1"
)
as
Label;
MainContact mc =
CharityChallenge_DAO.GetMainContactForCompany((e.Item.DataItem
as
Company).CompanyIdentifier);
if
(mc !=
null
)
contactName.Text = mc.FirstName +
" "
+ mc.LastName;
}
}
protected
void
rgCompany_NeedDataSource(
object
sender, GridNeedDataSourceEventArgs e)
{
List<Company> companyList = CharityChallenge_DAO.GetCompanies();
rgCompany.DataSource = companyList ??
new
List<Company>();
}
<
telerik:RadGrid
ID
=
"rgCompany"
runat
=
"server"
AutoGenerateColumns
=
"False"
CellSpacing
=
"0"
GridLines
=
"None"
oninsertcommand
=
"rgCompany_InsertCommand"
onitemcommand
=
"rgCompany_ItemCommand"
onneeddatasource
=
"rgCompany_NeedDataSource"
onupdatecommand
=
"rgCompany_UpdateCommand"
EnableLinqExpressions
=
"False"
AllowFilteringByColumn
=
"True"
AllowSorting
=
"True"
Height
=
"700px"
onitemdatabound
=
"rgCompany_ItemDataBound"
>
<
ClientSettings
>
<
Selecting
CellSelectionMode
=
"None"
></
Selecting
>
<
scrolling
allowscroll
=
"True"
usestaticheaders
=
"True"
/>
</
ClientSettings
>
<
MasterTableView
DataKeyNames
=
"CompanyIdentifier"
CommandItemDisplay
=
"Top"
ShowHeadersWhenNoRecords
=
"true"
AllowFilteringByColumn
=
"True"
NoMasterRecordsText
=
"No Companies have been added"
InsertItemDisplay
=
"Bottom"
GridLines
=
"None"
>
<
NoRecordsTemplate
><
div
style
=
"text-align: center;"
><
span
style
=
"color: Red;"
>No Companies have been added</
span
></
div
></
NoRecordsTemplate
>
<
CommandItemSettings
AddNewRecordText
=
"Add a Company"
/>
<
CommandItemTemplate
>
<
span
class
=
"radGridTitleSpan"
>Companies</
span
>
<
div
style
=
"text-align: right;"
>
<
asp:LinkButton
ID
=
"btnInsert"
runat
=
"server"
CommandName
=
"InitInsert"
class
=
"button secondaryAction"
>Add New Company</
asp:LinkButton
>
</
div
>
</
CommandItemTemplate
>
<
CommandItemSettings
AddNewRecordText
=
"Add a Company"
ExportToPdfText
=
"Export to PDF"
></
CommandItemSettings
>
<
RowIndicatorColumn
Visible
=
"True"
FilterControlAltText
=
"Filter RowIndicator column"
>
<
HeaderStyle
Width
=
"20px"
></
HeaderStyle
>
</
RowIndicatorColumn
>
<
ExpandCollapseColumn
Visible
=
"True"
FilterControlAltText
=
"Filter ExpandColumn column"
>
<
HeaderStyle
Width
=
"20px"
></
HeaderStyle
>
</
ExpandCollapseColumn
>
<
Columns
>
<
telerik:GridBoundColumn
FilterControlAltText
=
"Filter column column"
DataField
=
"CompanyIdentifier"
Visible
=
"False"
UniqueName
=
"CompanyIdentifier"
>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
FilterControlAltText
=
"Filter column1 column"
DataField
=
"CompanyName"
HeaderText
=
"Company Name"
FilterListOptions
=
"VaryByDataType"
UniqueName
=
"CompanyName"
>
</
telerik:GridBoundColumn
>
<
telerik:GridTemplateColumn
FilterControlAltText
=
"Filter TemplateColumn column"
FilterListOptions
=
"VaryByDataTypeAllowCustom"
HeaderText
=
"Company Contact"
UniqueName
=
"CompanyContact"
AllowFiltering
=
"True"
>
<
ItemTemplate
>
<
asp:Label
ID
=
"Label1"
runat
=
"server"
Text
=
""
></
asp:Label
>
</
ItemTemplate
>
</
telerik:GridTemplateColumn
>
<
telerik:GridBoundColumn
FilterControlAltText
=
"Filter column3 column"
DataField
=
"LastUpdatedUserIdentifier"
HeaderText
=
"Last Updated User Id"
UniqueName
=
"LastUpdatedUserIdentifier"
>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
FilterControlAltText
=
"Filter column4 column"
DataField
=
"LastUpdatedTimestamp"
HeaderText
=
"Last Updated Time"
UniqueName
=
"LastUpdatedTimestamp"
>
</
telerik:GridBoundColumn
>
<
telerik:GridEditCommandColumn
FilterControlAltText
=
"Filter EditCommandColumn column"
>
</
telerik:GridEditCommandColumn
>
</
Columns
>
<
EditFormSettings
EditFormType
=
"WebUserControl"
UserControlName
=
"CompanyWebCntrl.ascx"
>
<
EditColumn
FilterControlAltText
=
"Filter EditCommandColumn column"
></
EditColumn
>
</
EditFormSettings
>
</
MasterTableView
>
<
FilterMenu
EnableImageSprites
=
"False"
>
<
WebServiceSettings
>
<
ODataSettings
InitialContainerName
=
""
></
ODataSettings
>
</
WebServiceSettings
>
</
FilterMenu
>
<
HeaderContextMenu
CssClass
=
"GridContextMenu GridContextMenu_Default"
>
<
WebServiceSettings
>
<
ODataSettings
InitialContainerName
=
""
></
ODataSettings
>
</
WebServiceSettings
>
</
HeaderContextMenu
>
</
telerik:RadGrid>