我对此很陌生,所以请耐心等待
我正在使用 Telrik 的 RadListView 并尝试在 InsertItemTemplate 中使用复选框,但我似乎无法检索选中的值。我注意到的第一件事是,当我尝试将其写入时,intellesense 将无法识别我的 asp:checkbox id,因此我使用 FindControl 但是我在 Telerik 演示 () 中看到他们按名称访问复选框。无论如何,这就是我正在做的事情。如您所见,我想评估该复选框并根据在触发 Insert 时是否选中它来执行某些操作。
谢谢您的帮助
名单
<telerik:RadListView ID="IslandManagerList" runat="server" ItemPlaceholderID="IslandListContainer"
DataSourceID="dbIslandEditManager" AllowPaging="True" InsertItemPosition="FirstItem" OnNeedDataSource="IslandManagerList_NeedDataSource" DataKeyNames="ItemId">
<LayoutTemplate>
<section style="display: table; margin: 0px auto; width: auto;">
<telerik:RadDataPager ID="IslandManagerListPager" Skin="pj-Pager" EnableEmbeddedSkins="false"
runat="server" PagedControlID="IslandManagerList" PageSize="15">
<Fields>
<telerik:RadDataPagerButtonField FieldType="Prev" />
<telerik:RadDataPagerButtonField FieldType="Numeric" />
<telerik:RadDataPagerButtonField FieldType="Next" />
</Fields>
</telerik:RadDataPager>
</section>
<asp:Button ID="btnInitInsert" class="ui-like-button" runat="server" Text="Add an Island" OnClick="btnInitInsert_Click" />
<section>
<asp:PlaceHolder ID="IslandListContainer" runat="server"></asp:PlaceHolder>
</section>
</LayoutTemplate>
<ItemTemplate>
<section class="listview-item">
<section style="float: left; margin: 10px;">
<div style='width: 150px; height: 93px; background-color: #f7f7f7;'>
<p class="notice" style='position: absolute; z-index: 0; width: 120px; top: 35px;
left: 18px;'>
no image
</p>
<a href="/myislands/viewer?albumid=<%#Eval("ItemId")%>"><%#Eval("AlbumLogoSource")%></a></div>
</section>
<section style="float: left; width: 80%;">
<h3 style="margin: 10px 10px 5px 10px">
<a href="/myislands/viewer?albumid=<%#Eval("ItemId")%>"><%#Eval("Title")%></a> </h3>
<p style="font: 14px/20px tahoma; margin: 0px 10px 0px 10px;">
<%#Eval("Description")%></p>
</section>
<section class="photomanager-command-btns">
<asp:Button ID="editIsland" class="ui-like-button" runat="server" CommandName="Edit" Text="Edit" CausesValidation="false" />
<div class="ui-like-button" style="display:inline-block"><a id="uploadLink" href="/islands/tabid/917/ctl/upload/mid/1762/Default.aspx?aid=<%#Eval("ItemId")%>">Upload</a></div>
<div class="ui-like-button" style="display:inline-block"><a id="shareLink" href="/islanders?island=<%#Eval("ItemId")%>">Connect Friends</a></div>
</section>
</section>
</ItemTemplate>
<EditItemTemplate>
<section class="listview-item">
<section style="float: left; margin: 10px;">
<div style='width: 150px; height: 93px; background-color: #f7f7f7;'>
<p class="notice" style='position: absolute; z-index: 0; width: 120px; top: 35px;
left: 18px;'>
no image
</p>
<a href="/myislands/viewer?albumid=<%#Eval("ItemId")%>"><%#Eval("AlbumLogoSource")%></a></div>
</section>
<section style="position: relative; float: left; font: 14px/20px tahoma;margin: 10px 10px 10px 10px;">
<div style="overflow:hidden">
<div style="width: 75px; float: left; margin: 10px 10px 5px 10px">
title:</div>
<div style="float: left">
<asp:TextBox class="photomanager-edit-field" ID="updateTitle" runat="server" Text='<%# Bind("Title")%>'></asp:TextBox></div>
</div>
<div style="overflow:hidden">
<div style="width: 75px; float: left; margin: 0px 10px 10px 10px;">
about:
</div>
<div style="float: left">
<asp:TextBox class="photomanager-edit-field" ID="updateDescription" TextMode="MultiLine"
Columns="5" Rows="4" runat="server" Text='<%#Bind("Description")%>'></asp:TextBox></div>
</div>
</section>
<div style="position: absolute; bottom: 10px; right: 20px;">
<asp:Button Style="float: left" class="ui-like-button" ID="saveIslandUpdate" runat="server"
CommandName="Update" Text="Save" />
<asp:Button Style="float: left" class="ui-like-button" ID="cancelIslandUpdate" runat="server"
CommandName="Cancel" Text="Cancel" CausesValidation="false" />
</div>
</section>
</EditItemTemplate>
<InsertItemTemplate>
<section class="listview-item">
<section style="position: relative; float: left; font: 14px/20px tahoma; margin: 10px 10px 10px 10px;">
<div style="overflow: hidden">
<div style="width: 125px; float: left; margin: 10px 10px 5px 10px">
<h3>
Island Name:</h3>
</div>
<div style="float: left">
<asp:TextBox class="photomanager-edit-field" ID="tbTitle" runat="server" Text='<%# Bind("Title")%>'></asp:TextBox></div>
<asp:RequiredFieldValidator ID="rvTitle" runat="server" ControlToValidate="tbTitle"
ErrorMessage="Please give your Island a name" Display="Dynamic" />
</div>
<div style="overflow: hidden">
<div style="width: 125px; float: left; margin: 0px 10px 10px 10px;">
<h3>
About:</h3>
</div>
<div style="float: left">
<asp:TextBox class="photomanager-edit-field" ID="tbDescription" TextMode="MultiLine"
Columns="5" Rows="4" runat="server" Text='<%#Bind("Description")%>'></asp:TextBox>
<asp:RequiredFieldValidator ID="rvDescription" runat="server" ControlToValidate="tbDescription"
ErrorMessage="Please enter a little something about your Island" Display="Dynamic" />
</div>
</div>
</section>
<section style="position: relative; float: left; font: 14px/20px tahoma; margin: 10px 10px 10px 10px;">
<asp:CheckBox ID="makeIslandPublic" runat="server" CssClass="ui-like-button tooltip-item"
Checked="false" Text="Make this Island Viewable to the Public" /><div style="display: inline-block;
cursor: pointer;" class="tooltip-item">
<img src="images/icon_help_32px.gif" /></div>
<div class="show-tooltip" style="width: 250px;">
A public Island can be viewed by anyone. Use a public island when you want to show
of your works to the community and gain reputation to compete in fun contests</div>
</section>
<div style="position: absolute; bottom: 10px; right: 20px;">
<asp:Button ID="btnPerformInsert" class="ui-like-button" runat="server" Text="Add"
CommandName="PerformInsert" />
<asp:Button ID="BtnCancel" class="ui-like-button" runat="server" Text="Cancel" CommandName="Cancel"
CausesValidation="false" />
</div>
</section>
</InsertItemTemplate>
</telerik:RadListView>
protected void Page_Load(object sender, System.EventArgs e)
{
IslandManagerGrid.Visible = buttonToggleGridView.Checked;
IslandManagerList.Visible = buttonToggleListView.Checked;
}
protected void IslandManagerGridDataSource_Selecting(object sender, SqlDataSourceSelectingEventArgs e)
{
e.Command.Parameters["@AlbumOwner"].Value = base.UserId;
}
protected void btnInitInsert_Click(object sender, System.EventArgs e)
{
IslandManagerList.ShowInsertItem();
IslandManagerList.FindControl("btnInitInsert").Visible = false;
}
protected void IslandManagerGridDataSource_Inserting(object sender, SqlDataSourceCommandEventArgs e)
{
CheckBox PublicChecked = (CheckBox)IslandManagerList.FindControl("makeIslandPublic");
var isPublicChecked = PublicChecked.Checked;
if (isPublicChecked == true)
{
e.Command.Parameters["@ViewRoles"].Value = "All Users";
}
else
{
e.Command.Parameters["@ViewRoles"].Value = "Administrators";
}
e.Command.Parameters["@CreatedByUser"].Value = base.UserId;
e.Command.Parameters["@Owner"].Value = base.UserId;
}
#endregion