0
我想格式化網格視圖,就像我必須在網格視圖中顯示4個訂單,其中2個訂單具有狀態true,2個訂單具有狀態false現在我想應用這些訂單的樣式假狀態應在黃色可見,並且這些訂單是真的應該在正常的顏色,如黑色在這裏看到是我的網格視圖網格視圖樣式Asp.Net
<asp:GridView ID="CateringGridView" runat="server" AutoGenerateColumns="false" DataKeyNames="Id">
<RowStyle CssClass="GridRow" />
<Columns>
<asp:TemplateField HeaderText="First Name">
<ItemTemplate>
<asp:Label ID="Label1" runat="server" Text='<%#Bind("FirstName") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Last Name">
<ItemTemplate>
<asp:Label ID="Label1" runat="server" Text='<%#Bind("LastName") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Company Name">
<ItemTemplate>
<asp:Label ID="Label1" runat="server" Text='<%#Bind("CompanyName") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Email">
<ItemTemplate>
<asp:Label ID="Label1" runat="server" Text='<%#Bind("Email") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Phone">
<ItemTemplate>
<asp:Label ID="Label1" runat="server" Text='<%#Bind("Phone") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="People Attending">
<ItemTemplate>
<asp:Label ID="Label1" runat="server" Text='<%#Bind("PeopleAttending") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Event Type">
<ItemTemplate>
<asp:Label ID="Label1" runat="server" Text='<%#Bind("TypeOfEvent") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Event Date">
<ItemTemplate>
<asp:Label ID="Label1" runat="server" Text='<%#Bind("DateOfEvent") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
和我的隱藏文件的代碼是
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
this.FillCateringGrid();
}
}
private void FillCateringGrid()
{
using (CateringOrderDataContext dataContext = new CateringOrderDataContext())
{
var query = dataContext.Caterings
.Where(e => e.Status == true)
.Select(e => e);
this.CateringGridView.DataSource = query;
this.CateringGridView.DataBind();
}
}
其不能正常工作 – 2012-01-04 18:23:42
謹慎闡述? – 2012-01-04 18:25:27
我不明白你想說什麼,我只是複製粘貼你的代碼,並給我錯誤數據綁定表達式只支持具有DataBinding事件的對象。 System.Web.UI.WebControls.TableItemStyle沒有DataBinding事件。 – 2012-01-04 18:29:27