Hello
I'm having some problems trying to find the right code to display an image conditionally within a GridImageColumn. I have looked through all of your examples and guides, and cannot find one that I can relate to.
All of my code is written in C# and the grid is generated programatically.
The code above shows (with some properties stripped out) the Master Table View being initialised, and the use of the ImageUrl as one of the columns. This works fine, showing an image directly from a stored location. What I'm trying to do is set this value to what is stored within one of the Jobs object properties.
When I call the this.grid.NeedDataSource, this calls another method to calculate and populate the Jobs. This runs the following code to populate the securityImage variable, which is then set into the Jobs Object and returned in the data source:
All of my other columns are added using the following code:
I have tried using the following to set the image, but this just throws an error, as the value is expecting to be received in an array format. Are you able to help me understand whether this is the correct code to use, and if so, how to use it properly?
Many thanks,
Mark
I'm having some problems trying to find the right code to display an image conditionally within a GridImageColumn. I have looked through all of your examples and guides, and cannot find one that I can relate to.
All of my code is written in C# and the grid is generated programatically.
private
readonly
GridTableView detailTable;
private
readonly
RadGrid grid =
new
RadGrid();
private
void
InitialiseGrid()
{
this
.Page.ClientScript.RegisterStartupScript(
this
.GetType(),
"SearchGrid"
, Resources.SearchGrid,
true
);
grid.ID =
"grid"
;
grid.PagerStyle.AlwaysVisible =
true
;
this
.grid.ClientSettings.ClientEvents.OnRowDblClick =
"SearchGridRowDoubleClick"
;
this
.grid.MasterTableView.Name =
"Jobs"
;
this
.grid.MasterTableView.DataKeyNames =
new
[] {
"BatchId"
};
this
.grid.MasterTableView.ClientDataKeyNames =
new
[] {
"Id"
};
this
.grid.MasterTableView.HierarchyLoadMode = GridChildLoadMode.ServerOnDemand;
this
.grid.NeedDataSource += GridNeedDataSource;
this
.grid.DetailTableDataBind += GridDetailTableDataBind;
this
.grid.Columns.Add(
new
GridImageColumn { ImageUrl =
"Images/Tasks.ico"
});
The code above shows (with some properties stripped out) the Master Table View being initialised, and the use of the ImageUrl as one of the columns. This works fine, showing an image directly from a stored location. What I'm trying to do is set this value to what is stored within one of the Jobs object properties.
When I call the this.grid.NeedDataSource, this calls another method to calculate and populate the Jobs. This runs the following code to populate the securityImage variable, which is then set into the Jobs Object and returned in the data source:
var securityImage = userHasSecurityLevel ?
"Images/Edit1.png"
:
"Images/Delete.png"
All of my other columns are added using the following code:
this
.grid.Columns.Add(
new
GridBoundColumn { DataField =
"Surname"
, HeaderText = Resources.SurnameColumnText });
this
.grid.Columns.Add(
new
GridBoundColumn { DataField =
"Forename"
, HeaderText = Resources.FornameColumnText });
I have tried using the following to set the image, but this just throws an error, as the value is expecting to be received in an array format. Are you able to help me understand whether this is the correct code to use, and if so, how to use it properly?
this
.grid.Columns.Add(
new
GridImageColumn {
DataImageUrlFields =
"SecurityImage"
});
Many thanks,
Mark