0

私はこれにかなり慣れていないので、我慢してください

Telrik の RadListView を使用しており、InsertItemTemplate 内でチェックボックスを使用しようとしていますが、チェックされた値を取得できないようです。私が最初に気付いたのは、intellesense が asp:checkbox id を書き込もうとすると認識しないことです。そのため、FindControl を使用しますが、テレリック デモ () では、チェックボックスに名前でアクセスすることがわかります。とにかく、ここに私がやっていることがあります。ご覧のとおり、チェックボックスを評価し、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>&nbsp;&nbsp;&nbsp;</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
4

1 に答える 1

1

ListViewではなく各Item内にコントロールを見つける必要があると思います。

CheckBox PublicChecked = (CheckBox)currentItemFromList.FindControl("makeIslandPublic");
于 2012-09-27T15:22:16.070 に答える