本文介绍了将GridView中的CheckBoxField绑定到不支持布尔类型的Oracle的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个Gridview,其中有一些到数据源的boundfield列.我还有一个checkboxfield,如果要接收特定的整数值(1),我想对其进行检查,而对于(0),则不对其进行检查.因为我已经有一个问题,Oracle没有布尔类型和asp.net(取决于将复选框标记为boolean).请帮忙


I have a gridview with some boundfield columns to my data source. I have also a checkboxfield that I want checked it if it recieves a particular integer value (1) for example and unchecked it for (0). because I have a problem already that Oracle doesn''t have a boolean type and asp.net depending on boolean to mark the checkbox. Please help


<asp:GridView ID="GridView1" runat="server" AllowPaging="True" 

                    AutoGenerateColumns="False" CellPadding="4" 

                    DataSourceID="ObjectDataSource1" GridLines="None" 

                    onselectedindexchanged="GridView1_SelectedIndexChanged" PageSize="25" 

                    Height="402px" Width="818px" ForeColor="#333333" AllowSorting="True">
                    <PagerSettings FirstPageText="first" LastPageText="last" 

                        Position="TopAndBottom" Mode="NumericFirstLast" />
                    <RowStyle BackColor="#EFF3FB" />
                    <Columns>
                        <asp:CommandField ShowSelectButton="True" />
                        <asp:BoundField DataField="APPLICATION_NO" HeaderText="Application No." 

                            SortExpression="APPLICATION_NO" >
                            <HeaderStyle HorizontalAlign="Center" />
                            <ItemStyle HorizontalAlign="Center" />
                        </asp:BoundField>
                        <asp:BoundField DataField="SNAME" HeaderText="Name" 

                            SortExpression="SNAME" />
                        <asp:BoundField DataField="NATIONALITY" HeaderText="Nationality" 

                            SortExpression="NATIONALITY" >
                            <HeaderStyle HorizontalAlign="Left" />
                        </asp:BoundField>
                        <asp:BoundField DataField="APPLICATION_DT" HeaderText="Created Date" 

                            SortExpression="APPLICATION_DT" />
                            <asp:CheckBoxField DataField="ONLINE_CHECK" HeaderText="flag" SortExpression="ONLINE_CHECK" />
                    </Columns>
                    <FooterStyle BackColor="#507CD1" ForeColor="White" Font-Bold="True" />
                    <PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center" 

                        Font-Bold="True" Font-Size="Medium" />
                    <SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" />
                    <HeaderStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
                    <EditRowStyle BackColor="#2461BF" />
                    <AlternatingRowStyle BackColor="White" />
                </asp:GridView>

推荐答案

<asp:templatefield>
  <itemtemplate>
  <asp:checkbox id="chkOnlineCheck" runat="server" checked="<%# Eval("ONLINE_CHECK").ToString() == "0" ? false : true) %>" />' />
  </itemtemplate>
</asp:templatefield>



问候,
杰拉尔德



Regards,
Gerald


这篇关于将GridView中的CheckBoxField绑定到不支持布尔类型的Oracle的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-13 01:19