Gridview复选框消失了 [英] Gridview checkbox disappeared

查看:73
本文介绍了Gridview复选框消失了的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个gridview,可以获得所有的回弹电子邮件,我在gridview上添加了一个复选框,这是我的gridview代码

i have a gridview that get all of the bounceback emails i add a checkbox on the gridview and here's my code for the gridview

<pre><asp:GridView ID="GridView1" runat="server" ShowHeaderWhenEmpty="true" AutoGenerateColumns="False" BackColor="White" BorderColor="#CC9966" BorderStyle="None" BorderWidth="1px"  CellPadding="7" OnRowCommand="GridView1_RowCommand" >
            <HeaderStyle Width="10%" />
            <Columns>
                <asp:TemplateField HeaderText="Read ">
                    <ItemTemplate>
                       <asp:CheckBox runat="server" ID="CheckBoxRead" />
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:BoundField DataField="DateCreated" HeaderText="Date and Time" ItemStyle-Width="50%" ItemStyle-Wrap="false"  />
                <asp:BoundField DataField="ErrorTwo" HeaderText="Error" ItemStyle-Width="50%" ItemStyle-Wrap="false"  />
                <asp:TemplateField HeaderText="Receiver">
                    <ItemTemplate>
                       <asp:LinkButton runat="server" CommandArgument='<%# Eval("Sender") %>' Text='<%# Eval("Sender") %>'></asp:LinkButton> <%--OnClientClick="document.getElementById('id01').style.display='block'; return false"--%>
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:BoundField DataField="Subject" HeaderText="Email Error" ItemStyle-Width="50%" ItemStyle-Wrap="false"  />
                
                <asp:TemplateField HeaderText="Email Body">
                    <ItemTemplate>
                       <asp:Button ID="txtItemBody"  runat="server" Text='<%# Eval("EmailHeader") %>' Width="100px" Enabled="false"/>
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:TemplateField HeaderText="View Email ">
                    <ItemTemplate>
                       <asp:Button runat="server"  CommandName="Select" CommandArgument="<%# Container.DataItemIndex %>" Text="View Email" />
                    </ItemTemplate>
                </asp:TemplateField>
            </Columns>

</asp:GridView>





我尝试了什么:



我也加上



What I have tried:

and also i add

<meta http-equiv="Refresh" content="60" />





自动刷新页面并获取所有新数据和我的问题是如何设置复选框保留在窗体上,我也在服务器端设置回发。任何人帮我解决我的代码谢谢



to automatically refresh the page and to get all of the new data and my problem is how to set the checkbox to remain on the form, also i set a postback on the server side. anyone help me with my code thanks

推荐答案

使用J-query你可以保持复选框的状态。



取一个隐藏字段并将此隐藏字段值设置为1(如果用户选中复选框)和0如果用户取消选中该复选框

现在在document.ready函数上检查隐藏字段值并相应地勾选/取消选中该复选框。



问候

Sarita Singh
Using J-query you can maintain the state of the check box.

Take a hidden field and set this hidden field value to 1 ,if user checks the check box and 0 if user unchecked the checkbox
Now on document.ready function check the hidden-field value and check/unchecked the checkbox accordingly.

Regards
Sarita Singh


这篇关于Gridview复选框消失了的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆