Hello,
It's urgent.
Am using vb.net 2010.
I have master table view and detail table view with command items at top.
In master table view i can hide link button using
1. for Add new link button: Visible='<%# Not rgView1.MasterTableView.IsItemInserted %>'
2. for Cancel button: Visible='<%# rgView1.EditIndexes.Count > 0 Or rgView1.MasterTableView.IsItemInserted %>
How to achieve the above two in detail table?
I tried using Visible='<%# Not(Container AS GridItem).OwnerTableView.IsItemInserted %>'
But it throws error as Operator Not is not defined for type GridItem.
Please guide me
Thank you
Jayanthi
It's urgent.
Am using vb.net 2010.
I have master table view and detail table view with command items at top.
In master table view i can hide link button using
1. for Add new link button: Visible='<%# Not rgView1.MasterTableView.IsItemInserted %>'
2. for Cancel button: Visible='<%# rgView1.EditIndexes.Count > 0 Or rgView1.MasterTableView.IsItemInserted %>
How to achieve the above two in detail table?
I tried using Visible='<%# Not(Container AS GridItem).OwnerTableView.IsItemInserted %>'
But it throws error as Operator Not is not defined for type GridItem.
Please guide me
Thank you
Jayanthi
2 Answers, 1 is accepted
0
Shinu
Top achievements
Rank 2
answered on 10 May 2012, 06:49 AM
Hi Jayanthi,
Unfortunately i couldn't replicate the issue. I tried the same scenario and its working fine at my end. Can you provide the complete code so that I can use it to replicate the problem.
Thanks,
Shinu.
Unfortunately i couldn't replicate the issue. I tried the same scenario and its working fine at my end. Can you provide the complete code so that I can use it to replicate the problem.
Thanks,
Shinu.
0
jayanthi
Top achievements
Rank 1
answered on 10 May 2012, 07:03 AM
Thank you.
I have included my code.
I have included my code.
<%@ Page Title="" Language="VB" MasterPageFile="~/Main.master" AutoEventWireup="false" CodeFile="QuestionPaperIL.aspx.vb" Inherits="Question_Paper_IL_QuestionPaperIL" %>
<
asp:Content
ID
=
"Content1"
ContentPlaceHolderID
=
"head"
Runat
=
"Server"
>
<
style
type
=
"text/css"
>
.style25
{
width: 100%;
}
</
style
>
</
asp:Content
>
<
asp:Content
ID
=
"Content2"
ContentPlaceHolderID
=
"ContentPlaceHolder1"
Runat
=
"Server"
>
<
table
class
=
"style25"
>
<
tr
>
<
td
>
<
asp:Label
ID
=
"Label1"
runat
=
"server"
Font-Bold
=
"False"
Font-Italic
=
"False"
Font-Names
=
"Arial Rounded MT Bold"
ForeColor
=
"#009933"
Text
=
"Question Papers"
Font-Size
=
"Medium"
></
asp:Label
>
</
td
>
</
tr
>
<
tr
>
<
td
>
</
td
>
</
tr
>
<
tr
>
<
td
>
<
telerik:RadGrid
ID
=
"rgView1"
runat
=
"server"
AllowFilteringByColumn
=
"True"
AllowPaging
=
"True"
GridLines
=
"None"
ShowFooter
=
"True"
Skin
=
"Vista"
AutoGenerateColumns
=
"False"
CellPadding
=
"0"
>
<
MasterTableView
DataKeyNames
=
"RecordNo_PC"
CommandItemDisplay
=
"Top"
EnableColumnsViewState
=
"false"
Name
=
"Question_Master_IL"
InsertItemPageIndexAction
=
"ShowItemOnCurrentPage"
PageSize
=
"30"
>
<
CommandItemStyle
Wrap
=
"False"
/>
<
CommandItemTemplate
>
<
div
style
=
"padding: 5px 5px;"
>
<
asp:LinkButton
ID
=
"btnAdd"
CausesValidation
=
"false"
runat
=
"server"
CommandName
=
"InitInsert"
Visible='<%# Not rgView1.MasterTableView.IsItemInserted %>'><
img
style
=
"border:0px;vertical-align:middle;"
alt
=
""
src
=
"../Images/AddRecord.gif"
/> Add new Question set</
asp:LinkButton
>
<
asp:LinkButton
ID
=
"btnCancel"
CausesValidation
=
"false"
runat
=
"server"
ForeColor
=
"White"
CommandName
=
"CancelAll"
Visible='<%# rgView1.EditIndexes.Count > 0 Or rgView1.MasterTableView.IsItemInserted %>'><
img
style
=
"border:0px;vertical-align:middle;"
alt
=
""
src
=
"../Images/Cancel.gif"
/>Cancel editing</
asp:LinkButton
>
</
div
>
</
CommandItemTemplate
>
<
DetailTables
>
<
telerik:GridTableView
DataKeyNames
=
"RecordNo_PC"
Name
=
"Question_Detail_IL"
PageSize
=
"30"
CommandItemDisplay
=
"Top"
AllowFilteringByColumn
=
"true"
InsertItemPageIndexAction
=
"ShowItemOnCurrentPage"
>
<
ParentTableRelation
>
<
telerik:GridRelationFields
DetailKeyField
=
"RecordNo_PC"
MasterKeyField
=
"RecordNo_PC"
/>
</
ParentTableRelation
>
<
CommandItemTemplate
>
<
div
style
=
"padding: 5px 5px;"
>
<
asp:LinkButton
ID
=
"btnAddQuestion"
CausesValidation
=
"false"
runat
=
"server"
CommandName
=
"InitInsert"
Visible='<%# Not(Container AS GridItem).OwnerTableView.IsItemInserted %>' ><
img
style
=
"border:0px;vertical-align:middle;"
alt
=
""
src
=
"../Images/AddRecord.gif"
/> Add new Question</
asp:LinkButton
>
<
asp:LinkButton
ID
=
"btnCancel"
CausesValidation
=
"false"
runat
=
"server"
ForeColor
=
"White"
CommandName
=
"CancelAll"
Visible='<%# rgView1.EditIndexes.Count > 0 Or rgView1.MasterTableView.IsItemInserted %>'><
img
style
=
"border:0px;vertical-align:middle;"
alt
=
""
src
=
"../Images/Cancel.gif"
/>Cancel editing</
asp:LinkButton
>
<
asp:LinkButton
ID
=
"lnkExportToExcel"
runat
=
"server"
CausesValidation
=
"false"
CommandName
=
"ExportToExcel"
><
img
style
=
"border:0px;vertical-align:middle;"
alt
=
""
src
=
"../Images/excel.png"
/> Export to excel</
asp:LinkButton
>
<
asp:LinkButton
ID
=
"lnkExportToPDF"
runat
=
"server"
CausesValidation
=
"false"
CommandName
=
"ExportToPDF"
><
img
style
=
"border:0px;vertical-align:middle;"
alt
=
""
src
=
"../Images/reader.png"
/> Export to pdf</
asp:LinkButton
>
<
asp:LinkButton
ID
=
"lnkRefresh"
runat
=
"server"
CausesValidation
=
"false"
CommandName
=
"RebindGrid"
><
img
style
=
"border:0px;vertical-align:middle;"
alt
=
""
src
=
"../Images/Refresh.gif"
/> Refresh list</
asp:LinkButton
>
</
div
>
</
CommandItemTemplate
>
<
Columns
>
<
telerik:GridTemplateColumn
UniqueName
=
"No"
DataField
=
"No"
HeaderText
=
"No"
AllowFiltering
=
"false"
>
<
HeaderStyle
Font-Bold
=
"True"
></
HeaderStyle
>
<
ItemStyle
HorizontalAlign
=
"Left"
/>
<
ItemTemplate
>
<
asp:Label
ID
=
"lblNo1"
runat
=
"server"
Text='<% #Eval("No") %>'></
asp:Label
>
</
ItemTemplate
>
</
telerik:GridTemplateColumn
>
<
telerik:GridTemplateColumn
UniqueName
=
"QuestionNo"
DataField
=
"RecordNo_QNo"
HeaderText
=
"Question No"
>
<
HeaderStyle
Font-Bold
=
"True"
Wrap
=
"false"
></
HeaderStyle
>
<
ItemStyle
HorizontalAlign
=
"Left"
/>
<
ItemTemplate
>
<
asp:Label
ID
=
"lblRecordNo_QNo"
runat
=
"server"
Text='<% #Eval("RecordNo_QNo") %>'></
asp:Label
>
</
ItemTemplate
>
</
telerik:GridTemplateColumn
>
<
telerik:GridDateTimeColumn
UniqueName
=
"QuestionDate"
DataField
=
"QuestionDate"
HeaderText
=
"Question Date"
>
<
HeaderStyle
Font-Bold
=
"True"
Wrap
=
"false"
></
HeaderStyle
>
<
ItemStyle
HorizontalAlign
=
"Left"
/>
</
telerik:GridDateTimeColumn
>
<
telerik:GridTemplateColumn
UniqueName
=
"Question"
DataField
=
"Question"
HeaderText
=
"Question"
>
<
HeaderStyle
Font-Bold
=
"True"
></
HeaderStyle
>
<
ItemStyle
HorizontalAlign
=
"Left"
/>
<
ItemTemplate
>
<
asp:Label
ID
=
"lblQuestion"
runat
=
"server"
Text='<% #Eval("Question") %>'></
asp:Label
>
</
ItemTemplate
>
</
telerik:GridTemplateColumn
>
<
telerik:GridTemplateColumn
UniqueName
=
"Answer"
DataField
=
"Answer"
HeaderText
=
"Answer"
>
<
HeaderStyle
Font-Bold
=
"True"
></
HeaderStyle
>
<
ItemStyle
HorizontalAlign
=
"Left"
/>
<
ItemTemplate
>
<
asp:Label
ID
=
"lblAnswer"
runat
=
"server"
Text='<% #Eval("Answer") %>'></
asp:Label
>
</
ItemTemplate
>
</
telerik:GridTemplateColumn
>
<
telerik:GridEditCommandColumn
UniqueName
=
"EditCommandColumn"
ButtonType
=
"LinkButton"
>
</
telerik:GridEditCommandColumn
>
<
telerik:GridTemplateColumn
AllowFiltering
=
"false"
>
<
ItemTemplate
>
<
asp:LinkButton
ID
=
"link_btnDelete"
runat
=
"server"
CausesValidation
=
"false"
CommandName
=
"Delete"
OnClientClick='<% #Eval("RecordNo_QNo", " return confirm(""Are you sure to Delete {0}?"") ") %>'
Text="Delete"></
asp:LinkButton
>
</
ItemTemplate
>
</
telerik:GridTemplateColumn
>
<
telerik:GridTemplateColumn
UniqueName
=
"RecordNo_PC_Child"
DataField
=
"RecordNo_PC"
HeaderText
=
"RecordNo_PC"
Visible
=
"false"
>
<
HeaderStyle
Font-Bold
=
"True"
></
HeaderStyle
>
<
ItemStyle
HorizontalAlign
=
"Left"
/>
<
ItemTemplate
>
<
asp:Label
ID
=
"lblRecordNo_PC_Child"
runat
=
"server"
Text='<% #Eval ("RecordNo_PC") %>'></
asp:Label
>
</
ItemTemplate
>
</
telerik:GridTemplateColumn
>
</
Columns
>
<
EditFormSettings
UserControlName
=
"DetailQuestionIL.ascx"
EditFormType
=
"WebUserControl"
>
<
EditColumn
UniqueName
=
"editDetailQuestionEntryIL"
></
EditColumn
>
</
EditFormSettings
>
</
telerik:GridTableView
>
</
DetailTables
>
<
Columns
>
<
telerik:GridTemplateColumn
UniqueName
=
"RecordNo_PC"
DataField
=
"RecordNo_PC"
HeaderText
=
"RecordNo_PC"
Visible
=
"false"
>
<
HeaderStyle
Font-Bold
=
"True"
></
HeaderStyle
>
<
ItemStyle
HorizontalAlign
=
"Left"
/>
<
ItemTemplate
>
<
asp:Label
ID
=
"lblRecordNo_PC"
runat
=
"server"
Text='<% #Eval("RecordNo_PC") %>'></
asp:Label
>
</
ItemTemplate
>
</
telerik:GridTemplateColumn
>
<
telerik:GridTemplateColumn
UniqueName
=
"CertificationId"
DataField
=
"CertificationId"
HeaderText
=
"Certification ID"
>
<
HeaderStyle
Font-Bold
=
"True"
></
HeaderStyle
>
<
ItemStyle
HorizontalAlign
=
"Left"
/>
<
ItemTemplate
>
<
asp:Label
ID
=
"lblCertificationId"
runat
=
"server"
Text='<% #Eval("CertificationId") %>'></
asp:Label
>
</
ItemTemplate
>
</
telerik:GridTemplateColumn
>
<
telerik:GridTemplateColumn
UniqueName
=
"Certification"
DataField
=
"Certification"
HeaderText
=
"Certification Name"
>
<
HeaderStyle
Font-Bold
=
"True"
></
HeaderStyle
>
<
ItemStyle
HorizontalAlign
=
"Left"
/>
<
ItemTemplate
>
<
asp:Label
ID
=
"lblCertification"
runat
=
"server"
Text='<% #Eval("Certification") %>'></
asp:Label
>
</
ItemTemplate
>
</
telerik:GridTemplateColumn
>
<
telerik:GridTemplateColumn
UniqueName
=
"QSetId"
DataField
=
"QSetId"
HeaderText
=
"Question Set ID"
>
<
HeaderStyle
Font-Bold
=
"True"
></
HeaderStyle
>
<
ItemStyle
HorizontalAlign
=
"Left"
/>
<
ItemTemplate
>
<
asp:Label
ID
=
"lblQSetId"
runat
=
"server"
Text='<% #Eval("QSetId")%>'></
asp:Label
>
</
ItemTemplate
>
</
telerik:GridTemplateColumn
>
<
telerik:GridTemplateColumn
UniqueName
=
"QuestionSet"
DataField
=
"QuestionSet"
HeaderText
=
"Question Set"
>
<
HeaderStyle
Font-Bold
=
"True"
></
HeaderStyle
>
<
ItemStyle
HorizontalAlign
=
"Left"
/>
<
ItemTemplate
>
<
asp:Label
ID
=
"lblQuestionSet"
runat
=
"server"
Text='<% #Eval("QuestionSet") %>'></
asp:Label
>
</
ItemTemplate
>
</
telerik:GridTemplateColumn
>
</
Columns
>
<
EditFormSettings
UserControlName
=
"MasterQuestionIL.ascx"
EditFormType
=
"WebUserControl"
>
<
EditColumn
UniqueName
=
"editMasterQuestionEntryIL"
></
EditColumn
>
</
EditFormSettings
>
</
MasterTableView
>
<
GroupingSettings
CaseSensitive
=
"false"
/>
</
telerik:RadGrid
>
</
td
>
</
tr
>
</
table
>
</
asp:Content
>
Imports
System.Data
Imports
System.Data.SqlClient
Imports
System.Web.UI
Imports
Telerik.Web.UI
Partial
Class
Question_Paper_IL_QuestionPaperIL
Inherits
System.Web.UI.Page
Dim
sqlCon
As
String
Protected
Sub
rgView1_DetailTableDataBind(sender
As
Object
, e
As
Telerik.Web.UI.GridDetailTableDataBindEventArgs)
Handles
rgView1.DetailTableDataBind
Try
Dim
dataItem
As
GridDataItem =
CType
(e.DetailTableView.ParentItem, GridDataItem)
Dim
strSql
As
String
=
String
.Empty
Select
Case
e.DetailTableView.Name
Case
"Question_Detail_IL"
Dim
RecordNo_PC
As
Integer
= Val(dataItem.GetDataKeyValue(
"RecordNo_PC"
))
strSql =
"Select '' As No,RecordNo_QNo,Convert(varchar(100),QuestionDate,105) As QuestionDate,Question,Answer,t2.RecordNo_PC As RecordNo_PC From tbl_Question_Detail_IL As t1,tbl_Question_IL As t2 Where t1.RecordNo_PC=t2.RecordNo_PC And t2.RecordNo_PC="
& RecordNo_PC &
" Order By t1.RecordNo_QNo desc"
e.DetailTableView.DataSource = GetDataTable(strSql)
End
Select
Catch
ex
As
Exception
MsgBox(ex.ToString)
End
Try
End
Sub
Private
Function
GetDataTable(
ByVal
query
As
String
)
As
DataTable
da =
New
SqlDataAdapter
da.SelectCommand =
New
SqlCommand(query, con)
Dim
dt
As
New
DataTable
Dim
i
As
Integer
= 1
da.Fill(dt)
Dim
drw
As
DataRow
For
Each
drw
In
dt.Rows
drw(
"No"
) = i
i = i + 1
Next
Return
dt
End
Function
Protected
Sub
rgView1_ItemCommand(sender
As
Object
, e
As
Telerik.Web.UI.GridCommandEventArgs)
Handles
rgView1.ItemCommand
Try
If
e.CommandName =
"Edit"
Then
ElseIf
e.CommandName =
"InitInsert"
And
e.Item.OwnerTableView.Name =
"Question_Detail_IL"
Then
Dim
parentItem
As
GridDataItem = e.Item.OwnerTableView.ParentItem
Dim
lblRecordNo_PC
As
Label = TryCast(parentItem.FindControl(
"lblRecordNo_PC"
), Label)
Dim
lblCertificationId
As
Label = TryCast(parentItem.FindControl(
"lblCertificationId"
), Label)
Dim
lblCertification
As
Label = TryCast(parentItem.FindControl(
"lblCertification"
), Label)
Dim
lblQSetId
As
Label = TryCast(parentItem.FindControl(
"lblQSetId"
), Label)
Dim
lblQuestionSet
As
Label = TryCast(parentItem.FindControl(
"lblQuestionSet"
), Label)
If
Not
IsNothing(lblRecordNo_PC)
Then
Page.Items.Add(
"lblRecordNo_PC"
, Trim(lblRecordNo_PC.Text))
End
If
If
Not
IsNothing(lblCertificationId)
Then
Page.Items.Add(
"set_lblCertificationId"
, Trim(lblCertificationId.Text))
End
If
If
Not
IsNothing(lblCertification)
Then
Page.Items.Add(
"set_lblCertification"
, Trim(lblCertification.Text))
End
If
If
Not
IsNothing(lblQSetId)
Then
Page.Items.Add(
"set_lblQSetId"
, Trim(lblQSetId.Text))
End
If
If
Not
IsNothing(lblQuestionSet)
Then
Page.Items.Add(
"set_lblQuestionSet"
, Trim(lblQuestionSet.Text))
End
If
Page.Items.Add(
"btnClicked"
,
"InitInsert"
)
End
If
Catch
ex
As
Exception
End
Try
End
Sub
Protected
Sub
rgView1_NeedDataSource(sender
As
Object
, e
As
Telerik.Web.UI.GridNeedDataSourceEventArgs)
Handles
rgView1.NeedDataSource
Try
Dim
sql
As
String
sql =
"Select ''AS No,t1.RecordNo_PC,t1.CertificationId,t1.Certification,t2.QSetId,t2.QuestionSet From tbl_Question_IL As t1,tbl_Question_Set_IL As t2 Where t1.QSetId=t2.QSetId AND t1.CertificationId=t2.CertificationId Order By t1.RecordNo_PC"
cmd =
New
SqlCommand(sql, con)
da =
New
SqlDataAdapter()
da.SelectCommand = cmd
ds =
New
DataSet
da.Fill(ds)
rgView1.DataSource = ds.Tables(0)
Catch
ex
As
Exception
Response.Write(ex.Message.ToString)
End
Try
End
Sub
Protected
Sub
Page_Load(sender
As
Object
, e
As
System.EventArgs)
Handles
Me
.Load
If
Not
IsPostBack
Then
sqlCon = ConfigurationManager.ConnectionStrings(
"conn"
).ConnectionString
con =
New
SqlConnection(sqlCon)
If
con.State = ConnectionState.Closed
Then
con.Open()
End
If
End
If
End
Sub
End
Class