看板 C_Sharp 關於我們 聯絡資訊
我想要建立一個討論區的頁面 其中GridView有兩個欄位是ImageField 分別用來表示新文章(new),還有熱門文章(hot)的圖案 我必須讓這兩個欄位在滿足一定條件之後才顯示對應的圖案 程式碼如下 感謝回應 <Columns> <asp:BoundField DataField="name" HeaderText="標題" ReadOnly="True" SortExpression="name" /> <asp:ImageField DataImageUrlField="picture" NullImageUrl="~/images/new.gif" ReadOnly="True"> </asp:ImageField> 這個地方我該如何撰寫判斷式poDate >= dateTime.today ,並回傳結果給Visable屬性,控制圖樣顯示呢? <asp:ImageField DataImageUrlField="picture" NullImageUrl="~/images/hot.gif" ReadOnly="True"> </asp:ImageField> <asp:BoundField DataField="putOut" HeaderText="作者" ReadOnly="True" SortExpression="putOut" /> <asp:BoundField DataField="poDate" HeaderText="時間" ReadOnly="True" SortExpression="poDate" /> <asp:BoundField DataField="clickTimes" HeaderText="熱 門指數" ReadOnly="True" SortExpression="clickTimes" /> <asp:BoundField DataField="replyTimes" HeaderText="回 應篇數" ReadOnly="True" SortExpression="replyTimes" /> </Columns> -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 140.92.75.5 ※ 編輯: mygod1220 來自: 140.92.75.5 (04/25 12:11)
tomex:使用CodeBehind方式在GridView事件DataBound()中判斷比較佳 04/25 12:54
mygod1220:如果要直接屬性欄位判斷,要怎麼寫呢? 04/25 13:54