I would like to bind a radgrid that is within an itemtemplate of a list view. Nothing complicated. Just a grid in a list view. The grid will be bound from code behind and really has no dependance on the listview. The listview simply holds the grid.
ASPX:
Here is what I am attempting in code behind:
Any help much appreciated.
ASPX:
<
telerik:RadListView
ID
=
"RadListView1"
runat
=
"server"
>
<
LayoutTemplate
>
<
div
>
<
div
ID
=
"itemPlaceholder"
runat
=
"server"
>
</
div
>
</
div
>
</
LayoutTemplate
>
<
ItemTemplate
>
<
div
>
<
table
cellpadding
=
"0"
cellspacing
=
"0"
style
=
"width: 700px"
>
<
tr
>
<
td
style
=
"background-color: #597791"
>
<
img
alt
=
""
src
=
"../../../images/spacer_1h20w.png"
style
=
"width: 20px; height: 1px"
/>
</
td
>
</
tr
>
</
table
>
<
table
style
=
"width: 100%"
>
<
tr
>
<
td
class
=
"tbltd"
style
=
"width: 90px; color: #00B000;"
>
Bitech ID:</
td
>
<
td
style
=
"width: 221px"
>
<
strong
>
<
asp:Label
ID
=
"lbl_IDBitech"
runat
=
"server"
Text='<%# Eval("IDBitech") %>' ForeColor="#00B000" />
</
strong
>
</
td
>
<
td
class
=
"tbltd"
style
=
"width: 136px"
>
Site:</
td
>
<
td
>
<
asp:Label
ID
=
"lbl_Site"
runat
=
"server"
Text='<%# Eval("Site") %>' />
</
td
>
</
tr
>
<
tr
>
<
td
class
=
"tbltd"
style
=
"width: 90px"
>
Staff ID:</
td
>
<
td
style
=
"width: 221px"
>
<
asp:Label
ID
=
"lbl_StaffID"
runat
=
"server"
Text='<%# Eval("IDStaff") %>' />
</
td
>
<
td
class
=
"tbltd"
style
=
"width: 136px"
>
Phone:</
td
>
<
td
>
<
asp:Label
ID
=
"lbl_IPPhone"
runat
=
"server"
Text='<%# Eval("PhoneIP") %>' />
</
td
>
</
tr
>
<
tr
>
<
td
class
=
"tbltd"
style
=
"width: 90px"
>
User Name:</
td
>
<
td
style
=
"width: 221px"
>
<
asp:Label
ID
=
"lbl_UserName"
runat
=
"server"
Text='<%# Eval("UserName") %>' />
</
td
>
<
td
class
=
"tbltd"
style
=
"width: 136px"
>
Email:</
td
>
<
td
>
<
asp:Label
ID
=
"lbl_Email"
runat
=
"server"
Text='<%# Eval("EmailAddress") %>'></
asp:Label
>
</
td
>
</
tr
>
<
tr
>
<
td
class
=
"tbltd"
style
=
"width: 90px"
>
Last Name:</
td
>
<
td
style
=
"width: 221px"
>
<
asp:Label
ID
=
"lbl_LastName"
runat
=
"server"
Text='<%# Eval("LastName") %>' />
</
td
>
<
td
class
=
"tbltd"
style
=
"width: 136px"
>
</
td
>
<
td
>
</
td
>
</
tr
>
<
tr
>
<
td
class
=
"tbltd"
style
=
"width: 90px"
>
First Name:</
td
>
<
td
style
=
"width: 221px"
>
<
asp:Label
ID
=
"lbl_FirstName"
runat
=
"server"
Text='<%# Eval("FirstName") %>' />
</
td
>
<
td
class
=
"tbltd"
style
=
"width: 136px"
>
</
td
>
<
td
>
</
td
>
</
tr
>
<
tr
>
<
td
class
=
"tbltd"
style
=
"width: 90px"
>
Title:</
td
>
<
td
style
=
"width: 221px"
>
<
asp:Label
ID
=
"lbl_Title"
runat
=
"server"
Text='<%# Eval("JobTitle") %>' />
</
td
>
<
td
class
=
"tbltd"
style
=
"width: 136px"
>
</
td
>
<
td
>
</
td
>
</
tr
>
<
tr
>
<
td
class
=
"tbltd"
style
=
"width: 90px"
>
Password:</
td
>
<
td
style
=
"width: 221px"
>
<
asp:Label
ID
=
"lbl_Password"
runat
=
"server"
Text='<%# Eval("Password") %>' />
</
td
>
<
td
class
=
"tbltd"
style
=
"width: 136px"
>
</
td
>
<
td
>
</
td
>
</
tr
>
</
table
>
<
table
cellpadding
=
"0"
cellspacing
=
"0"
style
=
"width: 100%"
>
<
tr
>
<
td
style
=
"background-color: #597791"
>
<
img
alt
=
""
src
=
"../../../images/spacer_1h20w.png"
style
=
"width: 20px; height: 1px"
/>
</
td
>
</
tr
>
</
table
>
<
table
cellpadding
=
"0"
cellspacing
=
"0"
style
=
"width: 650px"
>
<
tr
>
<
td
>
</
td
>
<
td
>
</
td
>
<
td
>
</
td
>
<
td
>
</
td
>
<
td
>
</
td
>
</
tr
>
<
tr
>
<
td
>
<
table
cellpadding
=
"0"
cellspacing
=
"0"
style
=
"width: 105px; height: 24px; background-image: url('../../../images/rad_button.gif')"
>
<
tr
>
<
td
class
=
"rad_button"
style
=
"text-align: center"
>
<
asp:HyperLink
ID
=
"HyperLink2"
runat
=
"server"
CssClass
=
"rad_button"
NavigateUrl='<%# "user_details.aspx?
UserName
=
" + Eval("
UserName") %>'>Details</
asp:HyperLink
>
</
td
>
</
tr
>
</
table
>
</
td
>
<
td
>
<
table
cellpadding
=
"0"
cellspacing
=
"0"
style
=
"width: 105px; height: 24px; background-image: url('../../../images/rad_button.gif')"
>
<
tr
>
<
td
class
=
"rad_button"
style
=
"text-align: center"
>
<
asp:HyperLink
ID
=
"HyperLink1"
runat
=
"server"
NavigateUrl='<%# "user_change_site.aspx?
UserName
=
" + Eval("
UserName")%>'>Change Site</
asp:HyperLink
>
</
td
>
</
tr
>
</
table
>
</
td
>
<
td
>
<
table
cellpadding
=
"0"
cellspacing
=
"0"
style
=
"width: 105px; height: 24px; background-image: url('../../../images/rad_button.gif')"
>
<
tr
>
<
td
class
=
"rad_button"
style
=
"text-align: center"
>
<
asp:HyperLink
ID
=
"HyperLink3"
runat
=
"server"
NavigateUrl='<%# "user_change_name.aspx?
UserName
=
" + Eval("
UserName")%>'>Change Last Name</
asp:HyperLink
>
</
td
>
</
tr
>
</
table
>
</
td
>
<
td
>
<
table
cellpadding
=
"0"
cellspacing
=
"0"
style
=
"width: 105px; height: 24px; background-image: url('../../../images/rad_button.gif')"
>
<
tr
>
<
td
class
=
"rad_button"
style
=
"text-align: center"
>
<
asp:HyperLink
ID
=
"HyperLink4"
runat
=
"server"
NavigateUrl='<%# "user_disable.aspx?
UserName
=
" + Eval("
UserName")%>'>Disable</
asp:HyperLink
>
</
td
>
</
tr
>
</
table
>
</
td
>
<
td
>
<
table
cellpadding
=
"0"
cellspacing
=
"0"
style
=
"width: 105px; height: 24px; background-image: url('../../../images/rad_button.gif')"
>
<
tr
>
<
td
class
=
"rad_button"
style
=
"text-align: center"
>
<
asp:HyperLink
ID
=
"HyperLink5"
runat
=
"server"
NavigateUrl='<%# "user_delete.aspx?
UserName
=
" + Eval("
UserName")%>'>Delete</
asp:HyperLink
>
</
td
>
</
tr
>
</
table
>
</
td
>
</
tr
>
</
table
>
<
p
>
<
telerik:RadGrid
ID
=
"rgd_AreiesLog1"
runat
=
"server"
AutoGenerateColumns
=
"False"
GridLines
=
"None"
Skin
=
"WebBlue"
Width
=
"500px"
>
<
MasterTableView
DataKeyNames
=
"usr"
NoMasterRecordsText
=
"No Aeries data found."
>
<
CommandItemSettings
/>
<
Columns
>
<
telerik:GridBoundColumn
DataField
=
"dt"
HeaderStyle-HorizontalAlign
=
"Center"
HeaderText
=
"Login Date"
ItemStyle-HorizontalAlign
=
"Center"
SortExpression
=
"dt"
UniqueName
=
"dt"
>
<
HeaderStyle
HorizontalAlign
=
"Center"
/>
<
ItemStyle
HorizontalAlign
=
"Center"
/>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
DataField
=
"co"
HeaderStyle-HorizontalAlign
=
"Center"
HeaderText
=
"Aeries Version"
ItemStyle-HorizontalAlign
=
"Center"
SortExpression
=
"co"
UniqueName
=
"co"
>
<
HeaderStyle
HorizontalAlign
=
"Center"
/>
<
ItemStyle
HorizontalAlign
=
"Center"
/>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
DataField
=
"ip"
HeaderStyle-HorizontalAlign
=
"Center"
HeaderText
=
"IP Address"
ItemStyle-HorizontalAlign
=
"Center"
SortExpression
=
"ip"
UniqueName
=
"ip"
>
<
HeaderStyle
HorizontalAlign
=
"Center"
/>
<
ItemStyle
HorizontalAlign
=
"Center"
/>
</
telerik:GridBoundColumn
>
</
Columns
>
</
MasterTableView
>
</
telerik:RadGrid
>
<
br
/>
<
br
/>
<
br
/>
</
p
>
</
div
>
</
ItemTemplate
>
</
telerik:RadListView
>
Here is what I am attempting in code behind:
'***********************************************************************************************************************
'Search for users by UserName
'***********************************************************************************************************************
Protected
Sub
rcb_Users_SelectedIndexChanged(o
As
Object
, e
As
Telerik.Web.UI.RadComboBoxSelectedIndexChangedEventArgs)
Handles
rcb_Users.SelectedIndexChanged
Dim
cn
As
SqlConnection =
New
SqlConnection(ConfigurationManager.ConnectionStrings(
"IT_CentralConnectionString"
).ToString)
cn.Open()
Dim
SqlCmd
As
SqlCommand
SqlCmd =
New
SqlCommand(
"SELECT DisplayValue FROM ITC_Options WHERE NAME = 'AeriesDefaultYear'"
, cn)
Session(
"AeriesYear"
) =
CType
(SqlCmd.ExecuteScalar,
String
)
cn.Close()
rgd_User_List.DataSource = UserDetails_UserName()
rgd_AreiesLog.DataSource = AreiesLog_UserName()
rgd_PC_List.DataSource = WorkstationDetails_UserName()
rgd_User_List.DataBind()
rgd_AreiesLog.DataBind()
rgd_PC_List.DataBind()
RadListView1.DataSource = UserDetails_UserName()
RadListView1.DataBind()
Dim
rgd_AreiesLog1
As
RadGrid =
DirectCast
(RadListView1.ItemTemplate.FindControl(
"rgd_AreiesLog1"
), RadGrid)
rgd_AreiesLog1.DataSource = AreiesLog_UserName()
rgd_AreiesLog1.DataBind()
End
Sub
Private
Function
AreiesLog_UserName()
As
DataTable
Dim
DatabaseName
As
String
= Session(
"AeriesYear"
)
Dim
connectionString
As
String
=
DirectCast
(ConfigurationManager.ConnectionStrings(
"EagleAdmin_ConnectionString"
).ConnectionString,
String
)
Dim
connection
As
New
SqlConnection(connectionString)
Dim
command
As
New
SqlCommand(connectionString, connection)
command =
New
SqlCommand(
"aa_user_info"
, connection)
command.CommandType = CommandType.StoredProcedure
command.Parameters.Add(
"@DBName"
, SqlDbType.VarChar).Value = DatabaseName
If
rcb_Users.Text =
" "
Then
command.Parameters.Add(
"@UserName"
, SqlDbType.VarChar).Value =
"TUSTIN_NT\"
+ rcb_Users.SelectedValue
Else
command.Parameters.Add(
"@UserName"
, SqlDbType.VarChar).Value =
"TUSTIN_NT\"
+ rcb_Users.Text
End
If
command.Connection.Open()
Dim
myDataAdapter
As
New
SqlDataAdapter(command)
Dim
myDataSet
As
New
DataSet
Dim
dtData
As
New
DataTable
myDataAdapter.Fill(myDataSet)
Return
myDataSet.Tables(0)
command.Connection.Close()
End
Function
Private
Function
UserDetails_UserName()
As
DataTable
Dim
connectionString
As
String
=
DirectCast
(ConfigurationManager.ConnectionStrings(
"IT_CentralConnectionString"
).ConnectionString,
String
)
Dim
conn
As
New
SqlConnection(connectionString)
Dim
comm
As
New
SqlCommand(
"SELECT [UserName], [IDBitech], [IDStaff], [Password], [LastName], [Site], [JobTitle], [FirstName], [EmailAddress], [PhoneIP] FROM [vw_ADUsersExtended] WHERE ([UserName] LIKE @UserName + '%') ORDER BY UserName"
, conn)
comm.Connection.Open()
If
rcb_Users.Text =
" "
Then
comm.Parameters.Add(
"@UserName"
, SqlDbType.VarChar).Value = rcb_Users.SelectedValue
Else
comm.Parameters.Add(
"@UserName"
, SqlDbType.VarChar).Value = rcb_Users.Text
End
If
Dim
myDataAdapter
As
New
SqlDataAdapter(comm)
Dim
myDataSet
As
New
DataSet
Dim
dtData
As
New
DataTable
myDataAdapter.Fill(myDataSet)
Return
myDataSet.Tables(0)
comm.Connection.Close()
End
Function
Private
Function
WorkstationDetails_UserName()
As
DataTable
Dim
connectionString
As
String
=
DirectCast
(ConfigurationManager.ConnectionStrings(
"IT_CentralConnectionString"
).ConnectionString,
String
)
Dim
conn
As
New
SqlConnection(connectionString)
Dim
comm
As
New
SqlCommand(
"SELECT [LogonTime], [Host_Name], [IP_Address], [Boot_Time] FROM [vw_BG_ADSI_Extended] WHERE ([UserName] LIKE @UserName + '%') ORDER BY LogonTime DESC"
, conn)
comm.Connection.Open()
If
rcb_Users.Text =
" "
Then
comm.Parameters.Add(
"@UserName"
, SqlDbType.VarChar).Value = rcb_Users.SelectedValue
Else
comm.Parameters.Add(
"@UserName"
, SqlDbType.VarChar).Value = rcb_Users.Text
End
If
Dim
myDataAdapter
As
New
SqlDataAdapter(comm)
Dim
myDataSet
As
New
DataSet
Dim
dtData
As
New
DataTable
myDataAdapter.Fill(myDataSet)
Return
myDataSet.Tables(0)
comm.Connection.Close()
End
Function
Any help much appreciated.