动态添加gridview中的列

时间:2017-02-13 10:50:45

标签: c# asp.net gridview

我有一个gridview,其中列被动态绑定。列计数可能是7或12或17.it取决于用户选择。我想在rowdatabound方法中添加以下列。第一个问题是我无法设置rowdatabound中的列名和第二列是列数为0,第三列是无法访问的列。如果有人知道如何通过html表实现相同的功能..如果有人能找时间帮我解决请..

<Columns>
    <asp:BoundField HeaderText="Services"  DataField="Services" HeaderStyle-BackColor="#089de3" ItemStyle-Width="12%"> </asp:BoundField>
    <asp:BoundField HeaderText="Category"  DataField="Category" HeaderStyle-BackColor="#089de3" ItemStyle-Width="12%" > </asp:BoundField>
    <asp:CheckBoxField HeaderText="ALTA"  DataField="1_ALTA" HeaderStyle-BackColor="#e34e08" ItemStyle-Width="2%"   />
    <asp:CheckBoxField HeaderText="HPLAN"  DataField="1_HPLAN" HeaderStyle-BackColor="#e34e08" ItemStyle-Width="2%" />
    <asp:CheckBoxField  HeaderText="HOSP"  DataField="1_HOSP" HeaderStyle-BackColor="#e34e08" ItemStyle-Width="2%"/>
    <asp:CheckBoxField HeaderText="OTHER" DataField="1_OTHER"  HeaderStyle-BackColor="#e34e08" ItemStyle-Width="2%"/>
    <asp:BoundField HeaderText="OTHERSCOLOR" Visible="false" DataField="1_OthersColor" HeaderStyle-BackColor="#e34e08" ItemStyle-Width="2%"/>

    <asp:CheckBoxField HeaderText="ALTA"  DataField="2_ALTA" HeaderStyle-BackColor="#089de3" ItemStyle-Width="2%" />
    <asp:CheckBoxField HeaderText="HPLAN" DataField="2_HPLAN"  HeaderStyle-BackColor="#089de3" ItemStyle-Width="2%" />
    <asp:CheckBoxField HeaderText="HOSP" DataField="2_HOSP"  HeaderStyle-BackColor="#089de3" ItemStyle-Width="2%" />
    <asp:CheckBoxField HeaderText="OTHER" DataField="2_OTHER"  HeaderStyle-BackColor="#089de3" ItemStyle-Width="2%"/>
    <asp:BoundField HeaderText="OTHERSCOLOR" DataField="2_OthersColor" Visible="false" HeaderStyle-BackColor="#089de3" ItemStyle-Width="2%"/>

    <asp:CheckBoxField HeaderText="ALTA" DataField="3_ALTA"  HeaderStyle-BackColor="#e34e08" ItemStyle-Width="2%"  />
    <asp:CheckBoxField HeaderText="HPLAN" DataField="3_HPLAN"  HeaderStyle-BackColor="#e34e08" ItemStyle-Width="2%" />
    <asp:CheckBoxField HeaderText="HOSP" DataField="3_HOSP"  HeaderStyle-BackColor="#e34e08" ItemStyle-Width="2%" />
    <asp:CheckBoxField HeaderText="OTHER" DataField="3_OTHER"  HeaderStyle-BackColor="#e34e08" ItemStyle-Width="2%"/>
    <asp:BoundField HeaderText="OTHERSCOLOR" DataField="3_OthersColor" Visible="false" HeaderStyle-BackColor="#e34e08" ItemStyle-Width="2%"/>

</Columns>

0 个答案:

没有答案