Hello Telerik,
I have an embedded imagebutton in a RadGrid with grouping, the grid has an Item command as follows:
the image button code is as follows
xt_Imagebutton.ascx
xt_Imagebutton.ascx.cs
VideoSelector.ascx
What I am attempting to acheive is when the button's OnClick event is fired I want RadGrid1_ItemCommand to extract the MasterKeyValue of the Select command and pass the ID to the session variable XTV7_Videos_ID that is managed by the Session Handler GEEK (Geek.XTV7_Videos_ID)
The issue exists when the OnClick event is fired, for some reason the RadGrid1_ItemCommand does not get fired until after the OnClick event method is complete. so there for the CommandName="Select" is not occuring until after the fact.
How can I resolve this problem and get the ItemCommand firering as soon as the CommandName is hit or can I call/trigger the ItemCommand from the OnClick event?
Ever so grateful,
Trent
I have an embedded imagebutton in a RadGrid with grouping, the grid has an Item command as follows:
# region Radgrid code
protected
void
RadGrid1_ItemCommand(
object
source, GridCommandEventArgs e)
{
if
(e.CommandName ==
"Select"
)
{
//Session.Add("CustomerID", e.Item.Cells[3].Text.ToString());
Geek.XTV7_Videos_ID = e.Item.Cells[4].Text.ToString();
}
}
#endregion
the image button code is as follows
xt_Imagebutton.ascx
<
asp:ImageButton
ID
=
"btnImageDisplay"
runat
=
"server"
CommandName
=
"Select"
OnClick
=
"Image_Click"
Width
=
"120px"
/>
<
telerik:RadAjaxManager
ID
=
"RadAjaxManager1"
runat
=
"server"
/>
public
string
source
{
get
{
return
btnImageDisplay.ImageUrl;
}
set
{
btnImageDisplay.ImageUrl = value;
}
}
protected
void
Image_Click(
object
sender, ImageClickEventArgs e)
{
ReturnImages(Geek.XTV7_Videos_ID.ToString());
}
#region SQLCommands
public
void
ReturnImages(
string
VideoID)
{
if
(!String.IsNullOrEmpty(Geek.XTV7_Videos_ID.ToString()))
{
string
sql =
""
;
var dt =
new
DataTable();
sql +=
string
.Format(
"Select [XTV7_Videos_Image] From Xtrain.XTV7_2_Videos WHERE (XTV7_Videos_ID= {0})"
, VideoID);
dt = data.GetDataTable(sql);
if
(dt.Rows.Count > 0)
{
Geek.XTV7_Image = (dt.Rows[0][
"XTV7_Videos_Image"
].ToString()).ToString();
RadAjaxManager1.ResponseScripts.Add(
"radopen('Forms/View/ImageViewer.aspx','RadWindow2')"
);
}
dt.Dispose();
}
}
#endregion
<
telerik:RadGrid
ID
=
"RadGrid1"
runat
=
"server"
AllowFilteringByColumn
=
"True"
AutoGenerateColumns
=
"False"
BackColor
=
"White"
CellSpacing
=
"0"
DataSourceID
=
"SqlDataSource2"
EnableLinqExpressions
=
"False"
GridLines
=
"None"
Height
=
"650px"
AllowPaging
=
"True"
PageSize
=
"4"
OnItemCommand
=
"RadGrid1_ItemCommand"
ShowGroupPanel
=
"True"
>
<
ClientSettings
EnablePostBackOnRowClick
=
"true"
>
<
Selecting
AllowRowSelect
=
"True"
/>
<
ClientEvents
OnRowSelected
=
"RowSelected"
/>
<
Scrolling
AllowScroll
=
"True"
UseStaticHeaders
=
"True"
/>
</
ClientSettings
>
<
MasterTableView
AllowMultiColumnSorting
=
"true"
DataKeyNames
=
"XTV7_Videos_ID,XTV7_Videos_Image"
DataSourceID
=
"SqlDataSource2"
ShowGroupFooter
=
"false"
Summary
=
"Video Lessons"
>
<
CommandItemSettings
ExportToPdfText
=
"Export to PDF"
/>
<
GroupByExpressions
>
<
telerik:GridGroupByExpression
>
<
SelectFields
>
<
telerik:GridGroupByField
FieldAlias
=
":"
FieldName
=
"XTV7_Categories_Name"
/>
<
telerik:GridGroupByField
FieldAlias
=
"SubCategory"
FieldName
=
"XTV7_Categories_Sub_Name"
/>
</
SelectFields
>
<
GroupByFields
>
<
telerik:GridGroupByField
FieldName
=
"XTV7_Videos_Date_Uploaded"
HeaderText
=
"Sort By Date Uploaded"
SortOrder
=
"Descending"
/>
</
GroupByFields
>
</
telerik:GridGroupByExpression
>
</
GroupByExpressions
>
<
RowIndicatorColumn
FilterControlAltText
=
"Filter RowIndicator column"
>
</
RowIndicatorColumn
>
<
ExpandCollapseColumn
FilterControlAltText
=
"Filter ExpandColumn column"
>
</
ExpandCollapseColumn
>
<
Columns
>
<
telerik:GridTemplateColumn
AllowFiltering
=
"false"
HeaderStyle-Width
=
"110px"
HeaderText
=
"Lesson Snapshot"
ItemStyle-Width
=
"110px"
SortExpression
=
"XTV7_Categories_Image"
UniqueName
=
"XTV7_Categories_Sub_Image"
>
<
ItemTemplate
>
<%-- <
asp:ImageButton
ID
=
"btnImageDisplay"
runat
=
"server"
CommandName
=
"Select"
ImageUrl='<%# "~/App_Portal/xTrain/Images/VideoImages/" + Eval("XTV7_Videos_Image") %>' OnClick="Image_Click" Width="120px" />--%>
<
xTrain:xImgButton
ID
=
"xt_ImageButton1"
runat
=
"server"
source='<%# "~/App_Portal/xTrain/Images/VideoImages/" + Eval("XTV7_Videos_Image") %>' />
</
ItemTemplate
>
<
HeaderStyle
Width
=
"130px"
/>
<
ItemStyle
Width
=
"110px"
/>
</
telerik:GridTemplateColumn
>
<
telerik:GridBoundColumn
DataField
=
"XTV7_Videos_ID"
DataType
=
"System.Int32"
FilterControlAltText
=
"Filter XTV7_Videos_ID column"
HeaderText
=
"ID"
ItemStyle-Width
=
"20px"
ReadOnly
=
"False"
SortExpression
=
"XTV7_Videos_ID"
UniqueName
=
"XTV7_Videos_ID"
Visible
=
"False"
>
<
ItemStyle
Width
=
"20px"
/>
</
telerik:GridBoundColumn
>
<
telerik:GridTemplateColumn
AllowFiltering
=
"false"
HeaderStyle-Width
=
"50px"
ItemStyle-Width
=
"50px"
>
<
ItemTemplate
>
<
asp:ImageButton
ID
=
"imgbtnStartVideo"
runat
=
"server"
CommandName
=
"Select"
ImageUrl
=
"~/App_Themes/XGIS/Images/LessonLevels/PlayVideo32.png"
ToolTip
=
"Play Video"
/>
</
ItemTemplate
>
<
HeaderStyle
Width
=
"50px"
/>
<
ItemStyle
Width
=
"50px"
/>
</
telerik:GridTemplateColumn
>
<
telerik:GridTemplateColumn
AllowFiltering
=
"false"
HeaderStyle-Width
=
"50px"
ItemStyle-Width
=
"50px"
>
<
ItemTemplate
>
<
asp:ImageButton
ID
=
"imgbtnStartVideoIPOD"
runat
=
"server"
CommandName
=
"Select"
ImageUrl
=
"~/App_Themes/XGIS/Images/LessonLevels/IPAD30.png"
ToolTip
=
"Podcast"
/>
</
ItemTemplate
>
<
HeaderStyle
Width
=
"50px"
/>
<
ItemStyle
Width
=
"50px"
/>
</
telerik:GridTemplateColumn
>
<
telerik:GridBoundColumn
Aggregate
=
"Count"
AutoPostBackOnFilter
=
"true"
CurrentFilterFunction
=
"Contains"
DataField
=
"XTV7_Videos_Title"
EmptyDataText
=
"Search Titles"
FilterControlToolTip
=
"Search Titles"
FilterControlWidth
=
"200px"
FooterText
=
"Videos: "
HeaderStyle-Width
=
"240px"
HeaderText
=
"Search Video Titles"
ItemStyle-Width
=
"50px"
ItemStyle-Wrap
=
"true"
SortExpression
=
"XTV7_Videos_Title"
UniqueName
=
"XTV7_Videos_Title"
>
<
HeaderStyle
Width
=
"240px"
/>
<
ItemStyle
Width
=
"50px"
Wrap
=
"True"
/>
</
telerik:GridBoundColumn
>
<
telerik:GridTemplateColumn
AllowFiltering
=
"false"
DataField
=
"XTV7_Videos_Difficulty"
DataType
=
"System.Int32"
HeaderText
=
"Difficulty"
ItemStyle-Width
=
"20px"
SortExpression
=
"XTV7_Videos_Difficulty"
UniqueName
=
"XTV7_Videos_Difficulty"
>
<
ItemTemplate
>
<
asp:Image
ID
=
"imgD"
runat
=
"server"
ImageUrl='<%# GetImageUrl((int)Eval("XTV7_Videos_Difficulty")) %>' />
</
ItemTemplate
>
<
ItemStyle
Width
=
"20px"
/>
</
telerik:GridTemplateColumn
>
<
telerik:GridTemplateColumn
AllowFiltering
=
"false"
DataField
=
"XTV7_Videos_Captions"
DataType
=
"System.Byte"
HeaderText
=
"Captions"
ItemStyle-Width
=
"20px"
SortExpression
=
"XTV7_Videos_Captions"
UniqueName
=
"XTV7_Videos_Captions"
>
<
ItemTemplate
>
<
asp:Image
ID
=
"imgCaption"
runat
=
"server"
ImageUrl='<%# (bool)Eval("XTV7_Videos_Captions") ? "~/App_Themes/XGIS/images/boolean/true.gif" : "~/App_Themes/XGIS/images/boolean/false.gif" %>' />
</
ItemTemplate
>
<
ItemStyle
Width
=
"20px"
/>
</
telerik:GridTemplateColumn
>
<
telerik:GridBoundColumn
AllowFiltering
=
"False"
DataField
=
"XTV7_VideoHits"
DataType
=
"System.Int32"
FilterControlAltText
=
"Filter XTV7_VideoHits column"
HeaderText
=
"Hits"
SortExpression
=
"XTV7_VideoHits"
UniqueName
=
"XTV7_VideoHits"
>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
DataField
=
"XTV7_Videos_FileName"
DataType
=
"System.String"
HeaderText
=
"Hits"
SortExpression
=
"XTV7_Videos_FileName"
UniqueName
=
"XTV7_Videos_FileName"
Visible
=
"false"
>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
DataField
=
"XTV7_Videos_Date_Uploaded"
DataFormatString
=
"{0:d}"
DataType
=
"System.DateTime"
HeaderText
=
"Uploaded"
SortExpression
=
"XTV7_Videos_Date_Uploaded"
UniqueName
=
"XTV7_Videos_Date_Uploaded"
Visible
=
"false"
>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
DataField
=
"XTV7_Categories_Name"
HeaderText
=
"XTV7_Categories_Name"
SortExpression
=
"XTV7_Categories_Name"
UniqueName
=
"XTV7_Categories_Name"
Visible
=
"false"
>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
DataField
=
"XTV7_Categories_Sub_Name"
HeaderText
=
"XTV7_Categories_Sub_Name"
SortExpression
=
"XTV7_Categories_Sub_Name"
UniqueName
=
"XTV7_Categories_Sub_Name"
Visible
=
"false"
>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
DataField
=
"XTV7_Categories_ID"
DataType
=
"System.Int32"
HeaderText
=
"XTV7_Categories_ID"
SortExpression
=
"XTV7_Categories_ID"
UniqueName
=
"XTV7_Categories_ID"
Visible
=
"false"
ReadOnly
=
"false"
>
</
telerik:GridBoundColumn
>
</
Columns
>
<
EditFormSettings
>
<
EditColumn
FilterControlAltText
=
"Filter EditCommandColumn column"
>
</
EditColumn
>
</
EditFormSettings
>
</
MasterTableView
>
<
PagerStyle
EnableSEOPaging
=
"True"
PageButtonCount
=
"20"
/>
<
FilterMenu
EnableImageSprites
=
"False"
>
</
FilterMenu
>
<
HeaderContextMenu
CssClass
=
"GridContextMenu GridContextMenu_Black"
>
</
HeaderContextMenu
>
</
telerik:RadGrid
>
What I am attempting to acheive is when the button's OnClick event is fired I want RadGrid1_ItemCommand to extract the MasterKeyValue of the Select command and pass the ID to the session variable XTV7_Videos_ID that is managed by the Session Handler GEEK (Geek.XTV7_Videos_ID)
The issue exists when the OnClick event is fired, for some reason the RadGrid1_ItemCommand does not get fired until after the OnClick event method is complete. so there for the CommandName="Select" is not occuring until after the fact.
How can I resolve this problem and get the ItemCommand firering as soon as the CommandName is hit or can I call/trigger the ItemCommand from the OnClick event?
Ever so grateful,
Trent