I am getting the following error: "There was a problem extracting DataKeyValues from the DataSource. Please ensure that DataKeyNames are specified correctly and all fields specified exist in the DataSource."
I can bind a dataset to my grid and that displays properly. I have a master table with one detail table. When I try to put one of the master table rows in edit via clicking on an edit icon in the row and displaying the details in an edit form template, that's when the exception is thrown.
As you will see the Mastertable datakeynames is CourseId which maps to the element name of the dataset. Similarly the datakeynames is ChildCourseId for the GridTableView which also maps to the corresponding dataset.
I have looked at the documentation provided by Telerik and I believe I have coded the page correctly, but I am obviously missing something. Any insight/suggestions would be greatly appreciated.
Below are snippets from the aspx page, followed by the code behind and the methods used to build the dataset that is bound to the grid.
Thanks,
Dan
ASPX page:
Code behind....
...and the class to build the dataset...
I can bind a dataset to my grid and that displays properly. I have a master table with one detail table. When I try to put one of the master table rows in edit via clicking on an edit icon in the row and displaying the details in an edit form template, that's when the exception is thrown.
As you will see the Mastertable datakeynames is CourseId which maps to the element name of the dataset. Similarly the datakeynames is ChildCourseId for the GridTableView which also maps to the corresponding dataset.
I have looked at the documentation provided by Telerik and I believe I have coded the page correctly, but I am obviously missing something. Any insight/suggestions would be greatly appreciated.
Below are snippets from the aspx page, followed by the code behind and the methods used to build the dataset that is bound to the grid.
Thanks,
Dan
ASPX page:
<%@ Page Title="" Language="vb" AutoEventWireup="false" MasterPageFile="~/Templates/PortalBase.Master" CodeBehind="master_course_list.aspx.vb" Inherits="uo.FacultyPortal.web.course_filter" %>
<%@ Register Src="~/code/ucMessage.ascx" TagName="Message" TagPrefix="uc" %>
<
asp:Content
ID
=
"Content1"
ContentPlaceHolderID
=
"head"
runat
=
"server"
>
</
asp:Content
>
<
asp:Content
ID
=
"Content2"
ContentPlaceHolderID
=
"WorkPane"
runat
=
"server"
>
<
telerik:RadGrid
ID
=
"rgCourseInventoryList"
runat
=
"server"
CssClass
=
"RadGrid"
GridLines
=
"None"
AllowPaging
=
"True"
PageSize
=
"10"
AllowSorting
=
"True"
AutoGenerateColumns
=
"False"
ShowStatusBar
=
"true"
OnDetailTableDataBind
=
"rgCourseInventoryList_DetailTableDataBind"
OnNeedDataSource
=
"rgCourseInventoryList_NeedDataSource"
>
<
MasterTableView
CommandItemDisplay
=
"TopAndBottom"
DataKeyNames
=
"CourseId"
AutoGenerateColumns
=
"false"
HierarchyLoadMode
=
"ServerBind"
HierarchyDefaultExpanded
=
"true"
ClientDataKeyNames
=
"CourseId"
>
<
CommandItemSettings
AddNewRecordText="<%$ Resources:ui_messages, msgAddNewRecord %>" AddNewRecordImageUrl="../config/Images/Icons/addrecord.gif" RefreshText=""/>
<
CommandItemTemplate
>
<
asp:ImageButton
runat
=
"server"
ImageUrl
=
"../config/Images/Icons/addrecord.gif"
OnClientClick
=
"return ShowInsertForm();"
ID
=
"ibInsertForm"
ToolTip="<%$ Resources:ui_labels, ibShowDeleteForm %>"/>
</
CommandItemTemplate
>
<
Columns
>
<
telerik:GridEditCommandColumn
EditImageUrl
=
"../config/Images/Icons/edit.png"
ButtonType
=
"ImageButton"
ItemStyle-Width
=
"10px"
EditText="<%$ Resources:ui_labels, ibEditCourse %>">
</
telerik:GridEditCommandColumn
>
<
telerik:GridTemplateColumn
UniqueName
=
"gtcShowDelete"
ItemStyle-Width
=
"10px"
>
<
ItemTemplate
>
<
asp:ImageButton
runat
=
"server"
ImageUrl
=
"../config/Images/Icons/delete.png"
ID
=
"ibShowDeleteForm"
ToolTip="<%$ Resources:ui_labels, ibShowDeleteForm %>"/>
</
ItemTemplate
>
</
telerik:GridTemplateColumn
>
<
telerik:GridBoundColumn
UniqueName
=
"CourseCode"
HeaderText="<%$Resources:ui_labels, gbcCourseCode %>" DataField="SISCourseCode">
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
UniqueName
=
"CourseTitle"
DataField
=
"SISCourseTitle"
Visible
=
"false"
>
</
telerik:GridBoundColumn
>
<
telerik:GridTemplateColumn
UniqueName
=
"gtcTitle"
HeaderText="<%$ Resources:ui_labels, gtcTitle %>" ItemStyle-VerticalAlign="Middle">
<
ItemTemplate
>
<
asp:Image
ID
=
"imgParent"
runat
=
"server"
Visible
=
"false"
/>
<
asp:Label
ID
=
"lblParentTitle"
runat
=
"server"
></
asp:Label
>
<
asp:Label
ID
=
"lblCourseTitle"
runat
=
"server"
></
asp:Label
>
</
ItemTemplate
>
</
telerik:GridTemplateColumn
>
<
telerik:GridBoundColumn
UniqueName
=
"CourseNote"
HeaderText="<%$Resources:ui_labels, gbcNote %>" DataField="SISCourseNotes">
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
UniqueName
=
"CourseExpired"
DataField
=
"SISCourseExpired"
Visible
=
"false"
>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
UniqueName
=
"ParentId"
DataField
=
"ParentId"
Visible
=
"false"
>
</
telerik:GridBoundColumn
>
</
Columns
>
<
EditFormSettings
EditFormType
=
"Template"
>
<
FormTableItemStyle
width
=
"100%"
></
FormTableItemStyle
>
<
FormTableStyle
GridLines
=
"None"
CellSpacing
=
"0"
CellPadding
=
"2"
></
FormTableStyle
>
<
FormStyle
Width
=
"100%"
backColor
=
"white"
></
FormStyle
>
<
FormTemplate
>
<
asp:Table
ID
=
"tblCourseDetails"
CellSpacing
=
"2"
CellPadding
=
"1"
runat
=
"server"
BorderWidth
=
"1"
Width
=
"100%"
>
<
asp:TableRow
runat
=
"server"
ID
=
"trInternal"
>
<
asp:TableCell
runat
=
"server"
ID
=
"tcInternal"
>
<
asp:Table
ID
=
"tblInternal"
runat
=
"server"
>
<
asp:TableRow
ID
=
"trMessageArea"
runat
=
"server"
>
<
asp:TableCell
ID
=
"tcMessageArea"
runat
=
"server"
colspan
=
"2"
>
<
uc:Message
ID
=
"msgMessageArea"
runat
=
"server"
/>
</
asp:TableCell
>
</
asp:TableRow
>
<
asp:TableRow
runat
=
"server"
ID
=
"trCourseCode"
>
<
asp:TableCell
runat
=
"server"
ID
=
"tcCourseCode"
>
<
asp:Label
runat
=
"server"
ID
=
"lblCourseCode"
Text="<%$ Resources:ui_labels, lblCourseCode %>"></
asp:Label
>
</
asp:TableCell
>
<
asp:TableCell
runat
=
"server"
ID
=
"tcActivityCode2"
HorizontalAlign
=
"Left"
>
<
asp:TextBox
runat
=
"server"
ID
=
"txtSISCourseCode"
></
asp:TextBox
>
<
asp:Label
runat
=
"server"
ID
=
"lblCourseCodeMandatory"
Text="<%$ Resources:ui_labels, lblMandatoryFlag %>" CssClass="Mandatory"></
asp:Label
>
</
asp:TableCell
>
</
asp:TableRow
>
<
asp:TableRow
runat
=
"server"
ID
=
"tr1"
>
<
asp:TableCell
runat
=
"server"
ID
=
"tc1"
>
<
asp:Label
runat
=
"server"
ID
=
"lblCourseCategory"
Text="<%$ Resources:ui_labels, lblCourseCategory %>"></
asp:Label
>
</
asp:TableCell
>
<
asp:TableCell
runat
=
"server"
ID
=
"tc2"
HorizontalAlign
=
"Left"
>
<
telerik:RadComboBox
runat
=
"server"
ID
=
"rcbCourseCategory"
></
telerik:RadComboBox
>
<
asp:Label
runat
=
"server"
ID
=
"lblCourseCategoryMandatory"
Text="<%$ Resources:ui_labels, lblMandatoryFlag %>" CssClass="Mandatory"></
asp:Label
>
</
asp:TableCell
>
</
asp:TableRow
>
<
asp:TableRow
runat
=
"server"
ID
=
"tr2"
>
<
asp:TableCell
runat
=
"server"
ID
=
"tc3"
>
<
asp:Label
runat
=
"server"
ID
=
"lblCourseType"
Text="<%$ Resources:ui_labels, lblCourseType %>"></
asp:Label
>
</
asp:TableCell
>
<
asp:TableCell
runat
=
"server"
ID
=
"tc4"
HorizontalAlign
=
"Left"
>
<
telerik:RadComboBox
runat
=
"server"
ID
=
"rcbCourseType"
></
telerik:RadComboBox
>
<
asp:Label
runat
=
"server"
ID
=
"lblCourseTypeMandatory"
Text="<%$ Resources:ui_labels, lblMandatoryFlag %>" CssClass="Mandatory"></
asp:Label
>
</
asp:TableCell
>
</
asp:TableRow
>
<
asp:TableRow
runat
=
"server"
ID
=
"tr3"
>
<
asp:TableCell
runat
=
"server"
ID
=
"tc5"
>
<
asp:Label
runat
=
"server"
ID
=
"lblLanguage"
Text="<%$ Resources:ui_labels, lblLanguage %>"></
asp:Label
>
</
asp:TableCell
>
<
asp:TableCell
runat
=
"server"
ID
=
"tc6"
HorizontalAlign
=
"Left"
>
<
telerik:RadComboBox
runat
=
"server"
ID
=
"rcbLanguage"
></
telerik:RadComboBox
>
<
asp:Label
runat
=
"server"
ID
=
"lblLanguageMandatory"
Text="<%$ Resources:ui_labels, lblMandatoryFlag %>" CssClass="Mandatory"></
asp:Label
>
</
asp:TableCell
>
</
asp:TableRow
>
<
asp:TableRow
runat
=
"server"
ID
=
"tr4"
>
<
asp:TableCell
runat
=
"server"
ID
=
"tc7"
>
<
asp:Label
runat
=
"server"
ID
=
"lblAcademicUnit"
Text="<%$ Resources:ui_labels, lblAcademicUnit %>"></
asp:Label
>
</
asp:TableCell
>
<
asp:TableCell
runat
=
"server"
ID
=
"tc8"
HorizontalAlign
=
"Left"
>
<
telerik:RadComboBox
runat
=
"server"
ID
=
"rcbAcademicUnit"
MarkFirstMatch
=
"true"
></
telerik:RadComboBox
>
<
asp:Label
runat
=
"server"
ID
=
"lblAcademicUnitMandatory"
Text="<%$ Resources:ui_labels, lblMandatoryFlag %>" CssClass="Mandatory"></
asp:Label
>
</
asp:TableCell
>
</
asp:TableRow
>
<
asp:TableRow
runat
=
"server"
ID
=
"tr5"
>
<
asp:TableCell
runat
=
"server"
ID
=
"tc9"
>
<
asp:Label
runat
=
"server"
ID
=
"lblNumberOfSessions"
Text="<%$ Resources:ui_labels, lblNumberOfSessions %>"></
asp:Label
>
</
asp:TableCell
>
<
asp:TableCell
runat
=
"server"
ID
=
"tc10"
HorizontalAlign
=
"Left"
>
<
asp:TextBox
runat
=
"server"
ID
=
"txtNumberOfSessions"
></
asp:TextBox
>
</
asp:TableCell
>
</
asp:TableRow
>
<
asp:TableRow
runat
=
"server"
ID
=
"tr6"
>
<
asp:TableCell
runat
=
"server"
ID
=
"tc11"
>
<
asp:Label
runat
=
"server"
ID
=
"lblNote"
Text="<%$ Resources:ui_labels, lblNote %>"></
asp:Label
>
</
asp:TableCell
>
<
asp:TableCell
runat
=
"server"
ID
=
"tc12"
HorizontalAlign
=
"Left"
>
<
asp:TextBox
runat
=
"server"
ID
=
"txtNote"
Wrap
=
"true"
TextMode
=
"MultiLine"
Rows
=
"4"
Columns
=
"40"
></
asp:TextBox
>
</
asp:TableCell
>
</
asp:TableRow
>
<
asp:TableRow
runat
=
"server"
ID
=
"trCrossListCourse"
>
<
asp:TableCell
runat
=
"server"
ID
=
"tc13"
>
<
asp:Label
runat
=
"server"
ID
=
"lblCrossListCourseId"
Text="<%$ Resources:ui_labels, lblCrossListCourseId %>"></
asp:Label
>
</
asp:TableCell
>
<
asp:TableCell
runat
=
"server"
ID
=
"tc14"
HorizontalAlign
=
"Left"
>
<
asp:TextBox
runat
=
"server"
ID
=
"txtCrossListCourseCode"
></
asp:TextBox
>
</
asp:TableCell
>
</
asp:TableRow
>
<
asp:TableRow
runat
=
"server"
ID
=
"tr8"
>
<
asp:TableCell
runat
=
"server"
id
=
"tc15"
HorizontalAlign
=
"Left"
ColumnSpan
=
"2"
>
<
asp:Button
runat
=
"server"
ID
=
"btnUpdate"
Text="<%# IIf((TypeOf(Container) is GridEditFormInsertItem), Resources.ui_labels.btnAdd.ToString(), Resources.ui_labels.btnUpdate.ToString()) %>"
CommandName='<%# IIf((TypeOf(Container) is GridEditFormInsertItem), "PerformInsert", "Update") %>' />
<
asp:Button
runat
=
"server"
ID
=
"btnCancel"
CausesValidation
=
"false"
CommandName
=
"Cancel"
Text="<%$ Resources:ui_labels, btnCancel %>" />
</
asp:TableCell
>
</
asp:TableRow
>
</
asp:Table
>
</
asp:TableCell
>
</
asp:TableRow
>
</
asp:Table
>
</
FormTemplate
>
</
EditFormSettings
>
<
DetailTables
>
<
telerik:GridTableView
runat
=
"server"
DataKeyNames
=
"ChildCourseId"
Name
=
"CrossListView"
ClientDataKeyNames
=
"ChildCourseId"
>
<
Columns
>
<
telerik:GridButtonColumn
ImageUrl
=
"~/config/Images/Icons/lnk_del.png"
CommandName
=
"Delete"
Text="<%$ Resources:ui_messages, msgDeleteLink %>"
UniqueName="gbDeleteLink" ButtonType="ImageButton" ItemStyle-Width="10px" ConfirmText="<%$ Resources:ui_messages, msgConfirmDelete %>" ConfirmDialogType="Classic">
</
telerik:GridButtonColumn
>
<
telerik:GridTemplateColumn
UniqueName
=
"gtcShowDelete"
ItemStyle-Width
=
"10px"
>
<
ItemTemplate
>
<
asp:Image
runat
=
"server"
ImageUrl
=
"~/config/Images/Icons/lnk_chld.png"
/>
</
ItemTemplate
>
</
telerik:GridTemplateColumn
>
<
telerik:GridBoundColumn
UniqueName
=
"SISCourseCode"
DataField
=
"SISCourseCode"
>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
UniqueName
=
"SISCourseTitle"
DataField
=
"SISCourseTitle"
>
</
telerik:GridBoundColumn
>
<
telerik:GridBoundColumn
UniqueName
=
"SISCourseExpired"
DataField
=
"SISCourseExpired"
Visible
=
"false"
>
</
telerik:GridBoundColumn
>
</
Columns
>
</
telerik:GridTableView
>
</
DetailTables
>
</
MasterTableView
>
<
ClientSettings
>
<
Selecting
AllowRowSelect
=
"true"
></
Selecting
>
<
ClientEvents
OnRowDblClick
=
"RowDblClickEdit"
></
ClientEvents
>
</
ClientSettings
>
</
telerik:RadGrid
>
Code behind....
Imports Telerik.Web.UI
Imports uo.FacultyPortal.CourseOffer
Imports uo.FacultyPortal.Admin
Imports uo.FacultyPortal.Common
Imports uo.FacultyPortal.Common.Constants
Partial Class course_filter
Inherits CultureManager
Private cacheManager As New CacheManager
Private admin As CD_Tables = New CD_Tables
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If Not Page.IsPostBack Then
bindRadComboBox(rcbAcademicUnit, "CD_Academic_Unit")
bindRadComboBox(rcbCourseCategory, "CD_Course_Categories")
End If
End Sub
''' <
summary
>
''' Return a lst of courses to the user based on their selected criteria
''' </
summary
>
''' <
param
name
=
"sender"
></
param
>
''' <
param
name
=
"e"
></
param
>
''' <
remarks
></
remarks
>
Protected Sub btnSearch_Click(ByVal sender As Object, ByVal e As EventArgs) Handles btnSearch.Click
msgMessageArea.FlushMessages()
If rcbAcademicUnit.SelectedIndex <= 0 Then
msgMessageArea.AddMessage(Resources.ui_labels.lblAcademicUnit.ToString + Resources.ui_messages.errRequiredField.ToString,
Constants.uoMessageType.ErrorType)
Else
rgCourseInventoryList.Rebind()
rgCourseInventoryList.CurrentPageIndex = 0
End If
End Sub
Protected Sub rgCourseInventoryList_DetailTableDataBind(ByVal sender As Object, ByVal e As Telerik.Web.UI.GridDetailTableDataBindEventArgs) Handles rgCourseInventoryList.DetailTableDataBind
Dim oCourses As New Course
Dim oCourseInventory As New DataTable
Dim parentItem As GridDataItem = CType(e.DetailTableView.ParentItem, GridDataItem)
If parentItem.Edit Then
Return
End If
If e.DetailTableView.Name = "CrossListView" Then
Dim courseId As Integer = CInt(parentItem.GetDataKeyValue("CourseId"))
oCourseInventory = oCourses.getCrossListedCourses(courseId, IIf(cbShowDeleted.Checked, "Y", "N"))
e.DetailTableView.DataSource = oCourseInventory
End If
End Sub
''' <
summary
>
''' Get the data for the grid
''' </
summary
>
''' <
param
name
=
"source"
></
param
>
''' <
param
name
=
"e"
></
param
>
''' <
remarks
></
remarks
>
Protected Sub rgCourseInventoryList_NeedDataSource(ByVal source As Object, ByVal e As Telerik.Web.UI.GridNeedDataSourceEventArgs) Handles rgCourseInventoryList.NeedDataSource
Dim oCourses As New Course
Dim oCourseInventory As New DataTable
' Dim a As Integer = rgCourseInventoryList.CurrentPageIndex
If Not e.IsFromDetailTable Then 'andalso e.RebindReason <> GridRebindReason.InitialLoad Then
If e.RebindReason <> GridRebindReason.InitialLoad Then
oCourseInventory = oCourses.getCourseInventory(rcbAcademicUnit.SelectedValue, rcbCourseCategory.SelectedValue, IIf(cbShowDeleted.Checked, "Y", "N"))
rgCourseInventoryList.DataSource = oCourseInventory
End If
End If
End Sub
''' <
summary
>
''' If course is no longer offered then overstrike the course code and remove the delete icon
''' </
summary
>
''' <
param
name
=
"source"
></
param
>
''' <
param
name
=
"e"
></
param
>
''' <
remarks
></
remarks
>
Protected Sub rgCourseInventory_ItemDataBound(ByVal source As Object, ByVal e As Telerik.Web.UI.GridItemEventArgs) Handles rgCourseInventoryList.ItemDataBound
Dim dataItem As GridDataItem
Dim headerItem As GridHeaderItem
If TypeOf (e.Item) Is GridDataItem AndAlso e.Item.OwnerTableView.Name = "CrossListView" Then
dataItem = CType(e.Item, GridDataItem)
If dataItem("SISCourseExpired").Text <> " " Then
CType(dataItem("gbDeleteLink").Controls(0), ImageButton).Visible = False
dataItem("SISCourseCode").Font.Strikeout = True
End If
e.Item.OwnerTableView.ShowHeader = False
End If
If TypeOf (e.Item) Is GridDataItem AndAlso e.Item.OwnerTableView.NamingContainer.ID = "rgCourseInventoryList" Then
dataItem = CType(e.Item, GridDataItem)
If dataItem("CourseExpired").Text <> " " Then
CType(e.Item.FindControl("ibShowDeleteForm"), ImageButton).Visible = False
dataItem("CourseCode").Font.Strikeout = True
End If
Dim a As String = e.Item.OwnerTableView.DataKeyValues(e.Item.ItemIndex)("CourseId")
If dataItem("ParentId").Text <> " " Then
CType(e.Item.FindControl("ibShowDeleteForm"), ImageButton).Visible = False
CType(dataItem.FindControl("imgParent"), Image).ImageUrl = "../Images/Icons/lnk.png"
CType(dataItem.FindControl("imgParent"), Image).Visible = True
If dataItem("CourseExpired").Text <> " " Then
CType(dataItem.FindControl("lblParentTitle"), Label).Text = "(" + dataItem("ParentId").Text + ")"
CType(dataItem.FindControl("lblParentTitle"), Label).Font.Strikeout = True
CType(dataItem.FindControl("lblCourseTitle"), Label).Text = "<
br
>" + dataItem("CourseTitle").Text
Else
CType(dataItem.FindControl("lblCourseTitle"), Label).Text = "(" + dataItem("ParentId").Text + ")" + "<
br
>" + dataItem("CourseTitle").Text
End If
Else
CType(dataItem.FindControl("lblCourseTitle"), Label).Text = dataItem("CourseTitle").Text
End If
ElseIf TypeOf (e.Item) Is GridHeaderItem Then
headerItem = CType(e.Item, GridHeaderItem)
' headerItem
End If
End Sub
''' <
summary
>
''' Take action depending on what type of item it is.
''' </
summary
>
''' <
param
name
=
"source"
></
param
>)
''' <
param
name
=
"e"
></
param
>
''' <
remarks
></
remarks
>
Protected Sub rgCourseInventory_ItemCreated(ByVal source As Object, ByVal e As Telerik.Web.UI.GridItemEventArgs) Handles rgCourseInventoryList.ItemCreated
Dim courseId As String
Dim rcb As New RadComboBox
Dim oCourses As New Course
If TypeOf e.Item Is GridEditFormItem And e.Item.IsInEditMode Then
bindRadComboBox(CType(e.Item.FindControl("rcbCourseCategory"), RadComboBox), "CD_Course_Categories")
bindRadComboBox(CType(e.Item.FindControl("rcbCourseType"), RadComboBox), "CD_Course_Types")
bindRadComboBox(CType(e.Item.FindControl("rcbLanguage"), RadComboBox), "CD_Course_Languages")
bindRadComboBox(CType(e.Item.FindControl("rcbAcademicUnit"), RadComboBox), "CD_Academic_Unit")
' Are we editing an existing row?
If e.Item.ItemIndex >= 0 Then
' Then get the course details from the DB and bind the values to the list boxes.
courseId = e.Item.OwnerTableView.DataKeyValues(e.Item.ItemIndex)("CourseId")
oCourses.getCourseDetails(courseId)
' Hide the course code if we're editing. Only see it on a create.
CType(e.Item.FindControl("trCourseCode"), TableRow).Visible = False
CType(e.Item.FindControl("txtSISCourseCode"), TextBox).Text = oCourses.SISCourseCode
CType(e.Item.FindControl("rcbCourseCategory"), RadComboBox).SelectedValue = oCourses.CourseCategoryId
CType(e.Item.FindControl("rcbCourseType"), RadComboBox).SelectedValue = oCourses.CourseTypeId
CType(e.Item.FindControl("rcbLanguage"), RadComboBox).SelectedValue = oCourses.CourseLanguageId
CType(e.Item.FindControl("rcbAcademicUnit"), RadComboBox).SelectedValue = oCourses.AcademicUnitId
CType(e.Item.FindControl("txtNumberOfSessions"), TextBox).Text = oCourses.NumberOfSessions
CType(e.Item.FindControl("txtNote"), TextBox).Text = oCourses.Note
If Not oCourses.CrossListCourseCode Is Nothing Then
CType(e.Item.FindControl("trCrossListCourse"), TableRow).Visible = False
End If
End If
ElseIf TypeOf e.Item Is GridDataItem Then
If e.Item.OwnerTableView.NamingContainer.ID = "rgCourseInventoryList" Then
Dim clr As String = e.Item.Style("backgroundColor")
e.Item.Attributes.Add("onmouseover", "this.style.backgroundColor='lightsteelblue';this.style.cursor='hand';")
e.Item.Attributes.Add("onmouseout", "this.style.backgroundColor='" & clr & "';this.style.cursor='';")
Dim deleteForm As ImageButton = DirectCast(e.Item.FindControl("ibShowDeleteForm"), ImageButton)
deleteForm.Attributes("onclick") = [String].Format("return ShowDeleteForm('{0}','{1}');", e.Item.OwnerTableView.DataKeyValues(e.Item.ItemIndex)("CourseId"), e.Item.ItemIndex)
ElseIf e.Item.OwnerTableView.Name = "CrossListView" Then
Dim clr As String = e.Item.Style("backgroundColor")
e.Item.Attributes.Add("onmouseover", "this.style.backgroundColor='#cc99ff';this.style.cursor='hand';")
e.Item.Attributes.Add("onmouseout", "this.style.backgroundColor='" & clr & "';this.style.cursor='';")
End If
End If
If TypeOf e.Item Is GridDataItem Then
End If
End Sub
''' <
summary
>
''' Hide the empty rows in child gridview
''' </
summary
>
''' <
param
name
=
"sender"
></
param
>
''' <
param
name
=
"e"
></
param
>
''' <
remarks
></
remarks
>
Protected Sub rgCourseInventoryList_PreRender(ByVal sender As Object, ByVal e As System.EventArgs) Handles rgCourseInventoryList.PreRender
HideExpandColumnRecursive(rgCourseInventoryList.MasterTableView)
End Sub
''' <
summary
>
''' Recursively loop through grid looking for empty chidren and suppress the "No records found message" and the row.
''' </
summary
>
''' <
param
name
=
"tableView"
></
param
>
''' <
remarks
></
remarks
>
Private Sub HideExpandColumnRecursive(ByVal tableView As GridTableView)
Dim nestedViewItems As GridItem() = tableView.GetItems(GridItemType.NestedView)
For Each nestedViewItem As GridNestedViewItem In nestedViewItems
For Each nestedView As GridTableView In nestedViewItem.NestedTableViews
If nestedView.Items.Count = 0 Then
Dim cell As TableCell = nestedView.ParentItem("ExpandColumn")
cell.Controls(0).Visible = False
nestedViewItem.Visible = False
End If
If nestedView.HasDetailTables Then
HideExpandColumnRecursive(nestedView)
End If
Next
Next
End Sub
End Class
...and the class to build the dataset...
Option Strict On
Imports System.Data
Imports uo.Data
Imports log4net
Imports uo.FacultyPortal
Imports uo.FacultyPortal.Common
Imports System.Globalization
Imports System.Threading.Thread
Imports System.Text
Public Class Course
Public Function getCrossListedCourses(ByVal iCourseId As Integer, ByVal iShowDeleted As String) As DataTable
Dim oCourseCrossList As DataSet
Dim oGetCourseSchedule As XmlCallWrapper
Try
oGetCourseSchedule = XmlDatabase.CreateCallWrapper("FACULTYPORTAL", "PKG_COURSES.GET_CROSS_LISTED_COURSES_PRC")
oGetCourseSchedule("PN_COURSE_ID") = iCourseId
' TODO need to get language id
oGetCourseSchedule("PV_SHOW_EXPIRED") = iShowDeleted
oGetCourseSchedule("PN_INTERFACE_LANG_ID") = 1
oGetCourseSchedule.Execute()
oCourseCrossList = oGetCourseSchedule.GetDataSet
oCourseCrossList.Tables("PC_RESULT").Columns(0).ColumnName = "ChildCourseId"
oCourseCrossList.Tables("PC_RESULT").Columns(1).ColumnName = "SISCourseCode"
oCourseCrossList.Tables("PC_RESULT").Columns(2).ColumnName = "SISCourseTitle"
oCourseCrossList.Tables("PC_RESULT").Columns(3).ColumnName = "SISCourseExpired"
Catch ex As Exception
' log error
_logger.Error(ex)
Finally
End Try
Return oCourseCrossList.Tables("PC_RESULT")
End Function
Public Function getCourseInventory(ByVal iAcademicUnit As Integer, ByVal iCourseCategory As Integer, ByVal iShowDeleted As String) As DataTable
Dim oCourseSchedule As DataSet
Dim oGetCourseSchedule As XmlCallWrapper
Try
oGetCourseSchedule = XmlDatabase.CreateCallWrapper("FACULTYPORTAL", "PKG_COURSES.GET_COURSES_BY_UNIT_PRC")
oGetCourseSchedule("PN_ACADEMIC_UNIT_ID") = iAcademicUnit
oGetCourseSchedule("PN_COURSE_CATEGORY_ID") = IIf(iCourseCategory = 0, DBNull.Value, iCourseCategory)
oGetCourseSchedule("PV_SHOW_EXPIRED") = iShowDeleted
' TODO - Need to pass in or get the language
oGetCourseSchedule("PN_INTERFACE_LANG_ID") = 1
oGetCourseSchedule.Execute()
oCourseSchedule = oGetCourseSchedule.GetDataSet
oCourseSchedule.Tables("PC_RESULT").Columns(0).ColumnName = "CourseId"
oCourseSchedule.Tables("PC_RESULT").Columns(1).ColumnName = "SISCourseCode"
oCourseSchedule.Tables("PC_RESULT").Columns(2).ColumnName = "SISCourseTitle"
oCourseSchedule.Tables("PC_RESULT").Columns(3).ColumnName = "SISCourseNotes"
oCourseSchedule.Tables("PC_RESULT").Columns(4).ColumnName = "SISCourseExpired"
oCourseSchedule.Tables("PC_RESULT").Columns(5).ColumnName = "ParentId"
Catch ex As Exception
' log error
_logger.Error(ex)
Finally
End Try
Return oCourseSchedule.Tables("PC_RESULT")
End Function
Public Sub getCourseDetails(ByVal iCourseId As Integer)
Dim oCourseDetails As DataSet
Dim oGetCourseDetails As XmlCallWrapper
Try
oGetCourseDetails = XmlDatabase.CreateCallWrapper("FACULTYPORTAL", "PKG_COURSES.GET_COURSE_DETAILS_PRC")
oGetCourseDetails("PN_COURSE_ID") = iCourseId
oGetCourseDetails.Execute()
oCourseDetails = oGetCourseDetails.GetDataSet
CourseCategoryId = CInt(oCourseDetails.Tables("PC_RESULT")(0).Item("COURSE_CATEGORY_ID"))
CourseTypeId = CInt(oCourseDetails.Tables("PC_RESULT")(0).Item("COURSE_TYPE_ID"))
CourseLanguageId = CInt(oCourseDetails.Tables("PC_RESULT")(0).Item("LANGUAGE_ID"))
SISCourseCode = oCourseDetails.Tables("PC_RESULT")(0).Item("SIS_ACAD_ACT_CD").ToString
AcademicUnitId = CInt(oCourseDetails.Tables("PC_RESULT")(0).Item("UNIT_ID"))
NumberOfSessions = oCourseDetails.Tables("PC_RESULT")(0).Item("REG_SESSION_COUNT").ToString
Note = oCourseDetails.Tables("PC_RESULT")(0).Item("NOTE").ToString
CrossListCourseCode = CStr(oCourseDetails.Tables("PC_RESULT")(0).Item("CROSS_LIST_COURSE_ID"))
Catch ex As Exception
' log error
_logger.Error(ex)
Finally
End Try
End Sub
End Class