如何在条件下使用两列值在griedview中给出细胞前体

如何在条件下使用两列值在griedview中给出细胞前体

本文介绍了如何在条件下使用两列值在griedview中给出细胞前体的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

<asp:GridView ID="grdEmployeePeripheral" runat="server"

                                    AutoGenerateColumns="False" BackColor="White" BorderColor="#999999"

                                    BorderStyle="None" BorderWidth="1px" CellPadding="3" GridLines="Vertical"

                                    HorizontalAlign="Center"

                                    onrowdatabound="grdEmployeePeripheral_RowDataBound">
                                    <FooterStyle BackColor="#CCCCCC" ForeColor="Black" />
                                    <RowStyle BackColor="#EEEEEE" ForeColor="Black" />
                                    <Columns>

                                        <asp:BoundField DataField="PeripheralType" HeaderText="PeripheralType"

                                            SortExpression="PeripheralType" >
                                            <HeaderStyle HorizontalAlign="Center" />
                                            <ItemStyle HorizontalAlign="Center" />
                                        </asp:BoundField>
                                        <asp:BoundField DataField="Specification" HeaderText="Specification"

                                            SortExpression="Specification" >
                                            <HeaderStyle HorizontalAlign="Center" />
                                            <ItemStyle HorizontalAlign="Center" />
                                        </asp:BoundField>
                                          <asp:BoundField DataField="Remarks" HeaderText="Remarks"

                                            SortExpression="Remarks" >
                                            <HeaderStyle HorizontalAlign="Center" />
                                            <ItemStyle HorizontalAlign="Center" />
                                        </asp:BoundField>
                                          <asp:BoundField DataField="Warrenty" HeaderText="Warrenty"

                                            SortExpression="Warrenty" >
                                            <HeaderStyle HorizontalAlign="Center" />
                                            <ItemStyle HorizontalAlign="Center" />
                                        </asp:BoundField>
                                         <asp:BoundField DataField="PurchaseDate" HeaderText="Purchase Date"

                                            SortExpression="PurchaseDate" DataFormatString="{0:dd-MMM-yyyy}" >
                                            <HeaderStyle HorizontalAlign="Center" />
                                            <ItemStyle HorizontalAlign="Center" />
                                        </asp:BoundField>
                                         <asp:BoundField DataField="PeripheralAssignDate" HeaderText="Peripheral AssignDate"

                                            SortExpression="PeripheralAssignDate" DataFormatString="{0:dd-MMM-yyyy}" >
                                            <HeaderStyle HorizontalAlign="Center" />
                                            <ItemStyle HorizontalAlign="Center" />
                                        </asp:BoundField>

                                    </Columns>
                                    <FooterStyle BackColor="#CCCCCC" ForeColor="Black" />
                                    <PagerStyle BackColor="#999999" ForeColor="Black" HorizontalAlign="Center" />
                                    <SelectedRowStyle BackColor="#008A8C" Font-Bold="True" ForeColor="White" />
                                    <HeaderStyle BackColor="#000084" Font-Bold="True" ForeColor="White" />
                                    <AlternatingRowStyle BackColor="#DCDCDC" />
                                </asp:GridView>
















<pre lang="c#">

推荐答案

<asp:gridview id="grdEmployeePeripheral" runat="server" onrowdatabound="RowDataBound" xmlns:asp="#unknown">
<!---...  -->
</asp:gridview>







protected void RowDataBound(Object sender, GridViewRowEventArgs e)
{
    if(e.Row.RowType == DataControlRowType.DataRow)
    {
        if(e.Row.Cells[0].Text == "Emp" && e.Row.Cells[1].Text == "No")
                e.Row.Cells[0].ForeColor = Color.Red;
    }
}


这篇关于如何在条件下使用两列值在griedview中给出细胞前体的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-27 17:05