0

这是我在一个 ASPX 页面中的代码:

        <asp:GridView 
            ID="GridView1" 
            runat="server"
            AutoGenerateColumns="False"
            HorizontalAlign="Center"
            ShowHeader="False"
            DataSourceID="sqlTEST1">
            <Columns>
               <asp:BoundField DataField="stale" Visible="false" />
               <asp:BoundField DataField="bad" Visible="false" />
               <asp:BoundField DataField="ping" Visible="false" />
               <asp:BoundField DataField="max_tags" Visible="false" />
               <asp:BoundField DataField="aval_chck" Visible="false" />
               <asp:TemplateField>
                    <ItemTemplate>

                        <% 
                        if (Eval("aval_chck").ToString()=="1")
                        {
                            <table border="0" cellpadding="2" cellspacing="1">
                            <tr>
                                <td class="rowsBLACKMAINOFF" colspan="3"><a href="#"><asp:Label ID="Label2" runat="server" Text='<%# Bind("instalacja") %>'></asp:Label></a></td>
                            </tr>
                            <tr>
                                <td class="rowsBLACKROWOFF"><asp:Label ID="Label2" runat="server" Text='<%# Bind("stale") %>'></asp:Label></td>
                                <td class="rowsBLACKROWOFF"><asp:Label ID="Label3" runat="server" Text='<%# Bind("bad") %>'></asp:Label></td>
                                <td class="rowsBLACKROWOFF"><asp:Label ID="Label4" runat="server" Text='<%# Bind("ping") %>'></asp:Label></td>
                            </tr>
                            </table>                            
                        }
                        else
                        {
                            <table border="0" cellpadding="2" cellspacing="1">
                            <tr>
                                <td class="rowsBLACKMAIN" colspan="3"><asp:Label ID="Label2" runat="server" Text='<%# Bind("instalacja") %>'></asp:Label></td>
                            </tr>
                            <tr>
                                <td class="rowsNORMALc">&nbsp;</td>
                                <td class="rowsNORMALc">&nbsp;</td>
                                <td class="rowsNORMALc">&nbsp;</td>
                            </tr>
                            </table>
                        }
                        %>



                    </ItemTemplate>
                </asp:TemplateField>
            </Columns>
        </asp:GridView>

我知道这根本行不通。我只写了我想要达到的逻辑

我想让该声明发挥作用或做类似的事情。有任何想法吗?

4

1 回答 1

0

尝试 GridView.RowDataBound 事件

http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.gridview.rowdatabound.aspx

于 2012-07-05T14:42:36.813 回答