Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/31.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# ASP.NET UpdatePanel设置复选框的值_C#_Asp.net_Checkbox_Updatepanel - Fatal编程技术网

C# ASP.NET UpdatePanel设置复选框的值

C# ASP.NET UpdatePanel设置复选框的值,c#,asp.net,checkbox,updatepanel,C#,Asp.net,Checkbox,Updatepanel,我使用的是包含复选框的ListView。我想复选框自动更新我的数据库中的位字段,从假到真,或反之亦然 我不熟悉更新面板,我正在努力找到实现这一点的方法 我的列表视图 <asp:ListView ID="ListView1" runat="server" DataKeyNames="NotificationID" DataSourceID="SqlDataSource1"> <EmptyDataTemplate> <table runat="

我使用的是包含复选框的ListView。我想复选框自动更新我的数据库中的位字段,从假到真,或反之亦然

我不熟悉更新面板,我正在努力找到实现这一点的方法

我的列表视图

<asp:ListView ID="ListView1" runat="server" DataKeyNames="NotificationID" DataSourceID="SqlDataSource1">

    <EmptyDataTemplate>
        <table runat="server" style="">
            <tr>
                <td>No notifications exist.<br /> NOTE: You must be logged in to see notificaitons</td>
            </tr>
        </table>
    </EmptyDataTemplate>

    <ItemTemplate>
        <tr class="odd gradeX">
            <td><span style="display: none;"><%# ("00000000" + Eval("DateDescNumber")).TxtStrRight(8) %> - </span><%# GlobalUtilities.GetDiffDate(Convert.ToDateTime(Eval("DateTimeLogged"))) %></td>
            <td><%# Eval("UserName") %></td>
            <td><a href="<%# Eval("NotificationURL") %>"><%# Eval("NotificationTitle") %></a></td>
            <td class="center"><%# Eval("NotificationMessage") %></td>


            <td class="center">

                <asp:ScriptManager ID="ScriptManager1" runat="server">
                </asp:ScriptManager>

                <asp:updatepanel id="UpdatePanel1" runat="server">
                        <ContentTemplate>
                            <asp:CheckBox ID="CheckBoxMarkedAsRead" runat="server" 
                                Checked='<%# Eval("MarkedAsRead") %>' 
                                AutoPostBack="true" 
                                Visible="true" 
                                Text =" Not Selelected"
                                oncheckedchanged="CheckBox_MarkedAsRead_CheckedChanged" />
                        </ContentTemplate>
                </asp:updatepanel>

            </td>
        </tr>
    </ItemTemplate>

    <LayoutTemplate>

        <table cellpadding="0" cellspacing="0" border="0" class="responsive dynamicTable display table table-bordered" width="100%">
                    <thead>
                        <tr>
                            <th style="width:80px">Date</th>
                            <th>From</th>
                            <th>Notice</th>
                            <th>Description</th>
                            <th class="ch" style="width:53px;">Read</th>
                        </tr>
                    </thead>
                    <tbody>
                            <asp:PlaceHolder ID="itemPlaceholder" runat="server"></asp:PlaceHolder>
                    </tbody>
                </table>
    </LayoutTemplate>

</asp:ListView>

我已经在我的代码隐藏中创建了复选框\u MarkedAsRead\u CheckedChanged事件,至少我认为这是我应该做的,但是我尝试在代码隐藏中编写解决方案的脚本失败了一次又一次。

我没有。我尝试过的一切似乎都失败了。我无法从复选框中获取值。我希望过去可能有人做过这件事,也许有一个例子可以为我指明正确的方向。当然,人们过去也做过这件事。但我不能告诉你你做错了什么,除非你告诉我你做了什么。所以,展示你的代码,我可能会帮助你修复它,但我不会为你从头开始写整个东西。那样你学的不好。顺便说一下,我放弃了更新面板和事件处理程序后面的代码,转而使用AJAX和WebAPI函数来更新数据库。更干净,更容易使用服务器资源。谢谢Mason。我将研究如何做到这一点。这将花费你一点时间来学习,尽管这很值得!,我把它作为一个更好的体系结构的长期解决方案。但是,如果您从代码中发布事件处理程序,我们可能现在就可以让这个更新面板实现工作了。我尝试了一些方法,但放弃并删除了它,所以我现在没有任何东西可以展示给您。我甚至不确定自己是否朝着正确的方向前进,因为我对这一点还很陌生。这就是为什么我想在这里寻求一些建议。但我很感激你的建议,很明显我需要了解更多。再次感谢。