Hi,
I have a page with a grid and a commanditemtemplate with link buttons. I am trying to access the buttons in the command item template on the page pre-render event. Based on the samples I have found I added the following code to the pre-render event, but I keep getting the IndexOutOfRange exception error on the first line.
Private Sub WBC_SEC_Security_Users_PreRender(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.PreRender
Reading through the forums the problem seems to be caused by having the CommandItemDisplay property set to none but I have mine set to Top. The only thing that is different on my page is that it is has a master page.
Does anyone know what could be causing this problem.
Thank you for your help.
Tracy
I have a page with a grid and a commanditemtemplate with link buttons. I am trying to access the buttons in the command item template on the page pre-render event. Based on the samples I have found I added the following code to the pre-render event, but I keep getting the IndexOutOfRange exception error on the first line.
Private Sub WBC_SEC_Security_Users_PreRender(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.PreRender
Dim cmditem As GridCommandItem = DirectCast(rgvSecurityUsers.MasterTableView.GetItems(GridItemType.CommandItem)(0), GridCommandItem)
Dim lnkAdd As LinkButton = TryCast(cmditem.FindControl("lbtAdd"), LinkButton)
End Sub
Reading through the forums the problem seems to be caused by having the CommandItemDisplay property set to none but I have mine set to Top. The only thing that is different on my page is that it is has a master page.
Does anyone know what could be causing this problem.
Thank you for your help.
Tracy
<%@ Page Title="" Language="vb" AutoEventWireup="false" MasterPageFile="~/IPSMaster.Master" CodeBehind="WBC SEC Security Users.aspx.vb" Inherits="IPS_Gateway.WBC_SEC_Security_Users" %>
<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="act" %>
<
asp:Content
ID
=
"cntMain"
ContentPlaceHolderID
=
"cphMainContent"
runat
=
"server"
>
<
asp:SqlDataSource
ID
=
"SQLDS_SecurityUsers"
runat
=
"server"
ConnectionString="<%$ ConnectionStrings:IPSDataConnectionString %>"
SelectCommandType="StoredProcedure" SelectCommand="[Security].[DSP_SecurityUsers-SEL-INS-UPD-DEL]" >
<
SelectParameters
>
<
asp:Parameter
Name
=
"strCommandType"
Type
=
"String"
DefaultValue
=
"Select"
/>
</
SelectParameters
>
</
asp:SqlDataSource
>
<
asp:SqlDataSource
ID
=
"SQLDS_Employees"
runat
=
"server"
ConnectionString="<%$ ConnectionStrings:IPSDataConnectionString %>"
SelectCommandType="StoredProcedure" SelectCommand="[Employees].[DSP_EmployeeMaster-Select]" />
<
asp:SqlDataSource
ID
=
"SQLDS_SecurityType"
runat
=
"server"
ConnectionString="<%$ ConnectionStrings:IPSDataConnectionString %>"
SelectCommandType="StoredProcedure" SelectCommand="[Security].[DSP_SecurityIdentifiers-Select]" >
<
SelectParameters
>
<
asp:Parameter
Name
=
"strIdentifierType"
Type
=
"String"
DefaultValue
=
"Type"
/>
</
SelectParameters
>
</
asp:SqlDataSource
>
<
asp:SqlDataSource
ID
=
"SQLDS_SecurityStatus"
runat
=
"server"
ConnectionString="<%$ ConnectionStrings:IPSDataConnectionString %>"
SelectCommandType="StoredProcedure" SelectCommand="[Security].[DSP_SecurityIdentifiers-Select]" >
<
SelectParameters
>
<
asp:Parameter
Name
=
"strIdentifierType"
Type
=
"String"
DefaultValue
=
"Status"
/>
</
SelectParameters
>
</
asp:SqlDataSource
>
<
asp:panel
ID
=
"pnlPage"
runat
=
"server"
SkinId
=
"skn_GPC01_Panel_MainContent"
>
<
telerik:RadAjaxManager
ID
=
"RadAjaxManager2"
runat
=
"server"
>
<
AjaxSettings
>
<
telerik:AjaxSetting
AjaxControlID
=
"rgvSecurityGroups"
>
<
UpdatedControls
>
<
telerik:AjaxUpdatedControl
ControlID
=
"rgvSecurityUsers"
LoadingPanelID
=
"RadAjaxLoadingPanel1"
/>
<
telerik:AjaxUpdatedControl
ControlID
=
"rwmSecuritySettings"
/>
</
UpdatedControls
>
</
telerik:AjaxSetting
>
</
AjaxSettings
>
</
telerik:RadAjaxManager
>
<
telerik:RadAjaxLoadingPanel
ID
=
"RadAjaxLoadingPanel1"
runat
=
"server"
BackgroundPosition
=
"Center"
ZIndex
=
"150"
>
<
asp:Image
ID
=
"imgLoading"
runat
=
"server"
ImageUrl='<%$Resources:Images, LoadingBlack %>' AlternateText="Loading" />
</
telerik:RadAjaxLoadingPanel
>
<
asp:panel
ID
=
"pnlPageHeader"
runat
=
"server"
cssClass
=
"css_GPC01_Panel_PageHeading"
>
<
asp:Label
ID
=
"txtPageTitle"
runat
=
"server"
CssClass
=
"css_GPC01_Label_PageTitle"
Text
=
"Security Users"
/>
<
asp:ImageButton
ID
=
"ibtPageInformation"
runat
=
"server"
SkinID
=
"skn_GPC01_ImageButton_PageInformation"
/>
<
asp:HiddenField
ID
=
"hdfObjectId"
runat
=
"server"
/>
</
asp:panel
>
<
asp:Panel
ID
=
"pnlPageContent"
runat
=
"server"
cssClass
=
"css_GPC01_Panel_PageContent"
>
<
telerik:RadGrid
ID
=
"rgvSecurityUsers"
runat
=
"server"
DataSourceID
=
"SQLDS_SecurityUsers"
EnableEmbeddedSkins
=
"true"
Skin
=
"WebBlue"
AllowMultiRowSelection
=
"false"
AllowAutomaticDeletes
=
"True"
AllowAutomaticInserts
=
"True"
AllowAutomaticUpdates
=
"True"
AllowPaging
=
"True"
EnableViewState
=
"true"
AutoGenerateColumns
=
"False"
height
=
"560px"
>
<
PagerStyle
AlwaysVisible
=
"true"
Mode
=
"NextPrevAndNumeric"
/>
<
ClientSettings
AllowColumnsReorder
=
"false"
EnablePostBackOnRowClick
=
"true"
AllowExpandCollapse
=
"true"
>
<
Selecting
AllowRowSelect
=
"true"
/>
<
Scrolling
AllowScroll
=
"true"
UseStaticHeaders
=
"true"
/>
</
ClientSettings
>
<
MasterTableView
DataSourceID
=
"SQLDS_SecurityUsers"
DataKeyNames
=
"UserID, UserLoginId"
EditMode
=
"InPlace"
CommandItemDisplay
=
"Top"
PageSize
=
"30"
>
<
CommandItemTemplate
>
<
div
style
=
"padding: 5px 5px;"
>
<
asp:LinkButton
ID
=
"lbtAdd"
runat
=
"server"
CommandName
=
"InitInsert"
ToolTip
=
"Add New Group"
Visible='<%# Eval("hdfAdd") And (rgvSecurityUsers.EditIndexes.Count > 0 or Not rgvSecurityUsers.MasterTableView.IsItemInserted) %>'><
asp:Image
ID
=
"imgAdd"
runat
=
"server"
CssClass
=
"css_GFS01_Image_Align"
ImageURL="<%$ Resources:Images,AddRecord20%>" /> Add </
asp:LinkButton
>
<
asp:LinkButton
ID
=
"lbtEdit"
runat
=
"server"
CommandName
=
"EditSelected"
ToolTip
=
"Edit Group"
Visible='<%# Eval("hdfEdit") And (
rgvSecurityUsers.EditIndexes.Count
=
0
and Not rgvSecurityUsers.MasterTableView.IsItemInserted) %>'> <
asp:Image
ID
=
"Image1"
runat
=
"server"
CssClass
=
"css_GFS01_Image_Align"
ImageURL="<%$ Resources:Images, EditRecord20%>"/> Edit </
asp:LinkButton
>
<
asp:LinkButton
ID
=
"lbtCancel"
runat
=
"server"
CommandName
=
"CancelAll"
ToolTip
=
"Cancel Edit/Add"
Visible='<%# rgvSecurityUsers.EditIndexes.Count > 0 Or rgvSecurityUsers.MasterTableView.IsItemInserted %>'><
asp:Image
ID
=
"imgCancel"
runat
=
"server"
CssClass
=
"css_GFS01_Image_Align"
ImageURL="<%$ Resources:Images,CancelRecord20%>" /> Cancel </
asp:LinkButton
>
<
asp:LinkButton
ID
=
"lbtSaveNew"
runat
=
"server"
CommandName
=
"PerformInsert"
ToolTip
=
"Save New Group"
Visible='<%# rgvSecurityUsers.MasterTableView.IsItemInserted%>'><
asp:Image
ID
=
"imgSaveNew"
runat
=
"server"
CssClass
=
"css_GFS01_Image_Align"
ImageURL="<%$ Resources:Images,SaveRecord20%>" /> Save New</
asp:LinkButton
>
<
asp:LinkButton
ID
=
"lbtDelete"
runat
=
"server"
CommandName
=
"DeleteSelected"
ToolTip
=
"Delete Group"
Visible='<%# Eval("hdfDelete") And (
rgvSecurityUsers.EditIndexes.Count
=
0
and Not rgvSecurityUsers.MasterTableView.IsItemInserted) %>'><
asp:Image
ID
=
"imgDelete"
runat
=
"server"
CssClass
=
"css_GFS01_Image_Align"
ImageURL="<%$ Resources:Images,DeleteRecord20%>" />Delete </
asp:LinkButton
>
<
asp:LinkButton
ID
=
"lbtSave"
runat
=
"server"
CommandName
=
"UpdateEdited"
ToolTip
=
"Save Changes"
Visible='<%# rgvSecurityUsers.EditIndexes.Count > 0 AND Not rgvSecurityUsers.MasterTableView.IsItemInserted%>'><
asp:Image
ID
=
"Image2"
runat
=
"server"
CssClass
=
"css_GFS01_Image_Align"
ImageURL="<%$ Resources:Images,SaveRecord20%>" /> Update </
asp:LinkButton
>
<
asp:LinkButton
ID
=
"lbtSettings"
runat
=
"server"
CommandName
=
"ShowSettings"
ToolTip
=
"Edit/View Security Settings"
Visible='<%#
rgvSecurityUsers.EditIndexes.Count
=
0
AND Not rgvSecurityUsers.MasterTableView.IsItemInserted%>'><
asp:Image
ID
=
"Image3"
runat
=
"server"
CssClass
=
"css_GFS01_Image_Align"
ImageURL="<%$ Resources:Images,SecuritySettings20%>" /> Security Settings </
asp:LinkButton
>
<
asp:LinkButton
ID
=
"lbtRefresh"
runat
=
"server"
CommandName
=
"RebindGrid"
style
=
"position:absolute;Left:930px;"
><
asp:Image
id
=
"imgRefresh"
runat
=
"server"
CssClass
=
"css_GFS01_Image_Align"
ImageURL="<%$Resources:Images, ReloadBlue20 %>" />Refresh Grid</
asp:LinkButton
>
</
div
>
</
CommandItemTemplate
>
<
Columns
>
<
telerik:GridBoundColumn
DataField
=
"UserId"
UniqueName
=
"UserId"
HeaderText
=
"Id"
HeaderStyle-HorizontalAlign
=
"Left"
HeaderStyle-Width
=
"50px"
ReadOnly
=
"true"
/>
<
telerik:GridTemplateColumn
UniqueName
=
"gtcEmployeeNumber"
HeaderText
=
"Employee"
HeaderStyle-Width
=
"70px"
SortExpression
=
"EmployeeNumber"
>
<
FooterTemplate
> Template footer</
FooterTemplate
>
<
FooterStyle
VerticalAlign
=
"Middle"
HorizontalAlign
=
"Center"
/>
<
ItemTemplate
>
<%#DataBinder.Eval(Container.DataItem, "EmployeeNumber")%>
</
ItemTemplate
>
<
EditItemTemplate
>
<
telerik:RadComboBox
runat
=
"server"
ID
=
"EmployeeNumber"
DataSourceID
=
"SQLDS_Employees"
DataValueField
=
"EmployeeNumber"
DataTextField
=
"EmployeeName"
AutoPostBack
=
"true"
HighlightTemplatedItems
=
"true"
Height
=
"200px"
Width
=
"150px"
DropDownWidth
=
"400px"
OnSelectedIndexChanged
=
"OnSelectedIndexChangedHandler"
>
<
HeaderTemplate
>
<
ul
>
<
li
class
=
"css_GFS01_Combo_Col1"
>Name</
li
>
<
li
class
=
"css_GFS01_Combo_Col2"
>Emp#</
li
>
</
ul
>
</
HeaderTemplate
>
<
ItemTemplate
>
<
ul
>
<
li
class
=
"css_GFS01_Combo_Col1"
> <%#DataBinder.Eval(Container, "Text")%> </
li
>
<
li
class
=
"css_GFS01_Combo_Col2"
> <%#DataBinder.Eval(Container, "Value")%></
li
>
</
ul
>
</
ItemTemplate
>
</
telerik:RadComboBox
>
</
EditItemTemplate
>
</
telerik:GridTemplateColumn
>
<
telerik:GridBoundColumn
DataField
=
"UserName"
UniqueName
=
"UserName"
HeaderText
=
"User Name"
HeaderStyle-HorizontalAlign
=
"Left"
HeaderStyle-Width
=
"150px"
ColumnEditorID
=
"gtcEditor1"
/>
<
telerik:GridBoundColumn
DataField
=
"UserLoginId"
UniqueName
=
"UserLoginId"
HeaderText
=
"Login Id"
HeaderStyle-HorizontalAlign
=
"Left"
HeaderStyle-Width
=
"150px"
ColumnEditorID
=
"gtcEditor1"
/>
<
telerik:GridDropDownColumn
DataSourceID
=
"SQLDS_SecurityType"
DropDownControlType
=
"RadComboBox"
DataField
=
"SecurityType"
UniqueName
=
"SecurityType"
ListTextField
=
"Level2"
ListValueField
=
"Level2"
HeaderText
=
"Security Type"
HeaderStyle-Width
=
"100px"
DefaultInsertValue
=
"Group"
/>
<
telerik:GridDropDownColumn
DataSourceID
=
"SQLDS_SecurityStatus"
DropDownControlType
=
"RadComboBox"
DataField
=
"UserStatus"
UniqueName
=
"UserStatus"
ListTextField
=
"Level2"
ListValueField
=
"Level2"
HeaderText
=
"Status"
HeaderStyle-Width
=
"100px"
DefaultInsertValue
=
"Active"
/>
<
telerik:GridBoundColumn
DataField
=
"CreatedBy"
UniqueName
=
"CreatedBy"
HeaderText
=
"Created By"
HeaderStyle-HorizontalAlign
=
"Left"
HeaderStyle-Width
=
"100px"
ItemStyle-HorizontalAlign
=
"Left"
ReadOnly
=
"true"
/>
<
telerik:GridBoundColumn
DataField
=
"CreatedDate"
UniqueName
=
"CreatedDate"
HeaderText
=
"Created Date"
HeaderStyle-HorizontalAlign
=
"Center"
HeaderStyle-Width
=
"120px"
ItemStyle-HorizontalAlign
=
"Center"
DataType
=
"System.DateTime"
DataFormatString
=
"{0:MM/dd/yy h:mm:ss t}"
ReadOnly
=
"true"
/>
<
telerik:GridBoundColumn
DataField
=
"UpdatedBy"
UniqueName
=
"UpdatedBy"
HeaderText
=
"Updated By"
HeaderStyle-HorizontalAlign
=
"Left"
HeaderStyle-Width
=
"100px"
ItemStyle-HorizontalAlign
=
"Left"
ReadOnly
=
"true"
/>
<
telerik:GridBoundColumn
DataField
=
"UpdatedDate"
UniqueName
=
"UpdatedDate"
HeaderText
=
"Updated Date"
HeaderStyle-HorizontalAlign
=
"Center"
HeaderStyle-Width
=
"120px"
ItemStyle-HorizontalAlign
=
"Center"
DataType
=
"System.DateTime"
DataFormatString
=
"{0:MM/dd/yy h:mm:ss t}"
ReadOnly
=
"true"
/>
</
Columns
>
</
MasterTableView
>
</
telerik:RadGrid
>
<
telerik:GridTextBoxColumnEditor
ID
=
"gtcEditor1"
runat
=
"server"
TextBoxStyle-Width
=
"150px"
/> <
telerik:RadWindowManager
ID
=
"rwmMessageBox"
runat
=
"server"
Behaviors
=
"Close, Move"
EnableViewState
=
"false"
Animation
=
"Slide"
AnimationDuration
=
"5"
Height
=
"400"
Width
=
"400"
VisibleOnPageLoad
=
"true"
DestroyOnClose
=
"true"
Modal
=
"true"
EnableEmbeddedSkins
=
"true"
Skin
=
"Black"
/>
<
telerik:RadWindowManager
ID
=
"rwmSecuritySettings"
runat
=
"server"
Behaviors
=
"Close, Move"
EnableViewState
=
"false"
Animation
=
"Slide"
AnimationDuration
=
"5"
Height
=
"700"
Width
=
"835"
VisibleOnPageLoad
=
"true"
DestroyOnClose
=
"true"
Modal
=
"true"
Style
=
"z-index:3000"
/>
</
asp:Panel
>
<
asp:Panel
ID
=
"pnlFooter"
runat
=
"server"
CssClass
=
"css_GPC01_Panel_Footer"
>
<
asp:Label
ID
=
"lblReadOnly"
runat
=
"server"
Text
=
"Read Only"
CssClass
=
"css_GPC01_Footer_Labels"
/>
<
asp:Label
ID
=
"lblAdd"
runat
=
"server"
Text
=
"Add"
CssClass
=
"css_GPC01_Footer_Labels"
/>
<
asp:Label
ID
=
"lblEdit"
runat
=
"server"
Text
=
"Edit"
CssClass
=
"css_GPC01_Footer_Labels"
/>
<
asp:Label
ID
=
"lblDelete"
runat
=
"server"
Text
=
"Delete"
CssClass
=
"css_GPC01_Footer_Labels"
/>
<
asp:Label
ID
=
"lblObject"
runat
=
"server"
Text
=
"Object"
CssClass
=
"css_GPC01_Footer_Labels"
/>
<
asp:HiddenField
ID
=
"hdfReadOnly"
runat
=
"server"
/>
<
asp:HiddenField
ID
=
"hdfAdd"
runat
=
"server"
/>
<
asp:HiddenField
ID
=
"hdfEdit"
runat
=
"server"
/>
<
asp:HiddenField
ID
=
"hdfDelete"
runat
=
"server"
/>
</
asp:Panel
>
</
asp:panel
>
</
asp:Content
>
Reading through the forums the problem seems to be caused by not having the CommandItemDisplay property set to none but I have mine set to Top. The only thing that is different on my page is that it is has a master page.