以编程方式将复选框列添加到asp.net gridview

时间:2014-11-25 10:23:06

标签: c# asp.net sql-server gridview stored-procedures

我正在从存储过程将数据加载到gridview,我想要的是以编程方式在gridview中包含一个复选框,我能够通过此链接Adding All Rows Checkbox for Unknown Gridview Data Source

获取该信息。

存储的专业版部分包含复选框

select 
   fields...
   'chkApprove' = 0x1
from 
   tablename

源视图中的gridview定义asp.net

 <asp:GridView ID="grdDSTR" runat="server" BackColor="White" BorderColor="#DEDFDE" BorderStyle="None"
                         BorderWidth="1px" CellPadding="4" ForeColor="Black" GridLines="Vertical"  Font-Size="Smaller" 
                        EmptyDataText="No Records Found" ShowHeaderWhenEmpty="True" width="100%" AutoGenerateColumns="false">


      <Columns>
     <asp:BoundField HeaderText="Name" DataField="Name" />
     <asp:BoundField HeaderText="Date" DataField="Date" />
     <asp:BoundField HeaderText="Day" DataField="Day" />
     <asp:BoundField HeaderText="Surcharge" DataField="Surcharge" />
     <asp:BoundField HeaderText="Senior" DataField="Senior" />
     <asp:BoundField HeaderText="VES" DataField="VES" />
     <asp:BoundField HeaderText="Other" DataField="Other" />
     <asp:BoundField HeaderText="Refund" DataField="Refund" />
     <asp:BoundField HeaderText="Void" DataField="Void" />
      <asp:BoundField HeaderText="GSC" DataField="GSC" />
     <asp:BoundField HeaderText="Cash" DataField="Cash" />
     <asp:BoundField HeaderText="Charge" DataField="Charge" />
     <asp:BoundField HeaderText="Gift" DataField="Gift" />
    <asp:CheckBoxField DataField="chkApprove" HeaderText="Approve" />    

我注意到,每行的复选框都被禁用,默认情况下会自动检查所有复选框。

我想要的输出只应检查与行计算中的条件匹配的行。如何创建一个简单的条件,例如当GSC数据超过10,000时,应该选中复选框?否则,请不要选中

enter image description here

0 个答案:

没有答案