|
code
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Gridview -- changing field contentgridview based on the content of the other other fields in the row. Can anyone point me in the right direction? I tried the following code as a test: Protected Sub gvRadTurnat_RowCreated(ByVal sender As Object, ByVal e As GridViewRowEventArgs) If e.Row.RowType = DataControlRowType.DataRow Then If CType(DataBinder.Eval(e.Row.DataItem, "193hrs"), Integer) > 0 Then e.Row.Cells(0).Style("background-image") = "redcircle.gif" End If End If End Sub What I thought this would do is when a row is created if the DataBound field of "193hrs" had a value greater than 0 it would set the background image for the cell to "redcircle.gif". Maybe add an image control to the first column instead of setting the
background-image. <%@ Page Language="VB" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <script runat="server"> Protected Sub GridView1_RowDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) If e.Row.RowType = DataControlRowType.DataRow Then Dim i As New Image i.Width = New Unit(60, UnitType.Pixel) i.Height = New Unit(60, UnitType.Pixel) If Len(e.Row.Cells(1).Text) < 10 Then i.ImageUrl = "http://www.ultraweaver.com/downloads/files/smiley.jpg" Else i.ImageUrl = "http://www.discshoppe.com/Merchant2/graphics/00000001/other/uncle-smiley-240.jpg" End If e.Row.Cells(0).Controls.Add(i) End If End Sub </script> <html xmlns="http://www.w3.org/1999/xhtml" > <head runat="server"> <title>Untitled Page</title> </head> <body> <form id="form1" runat="server"> <div> <asp:GridView ID="GridView1" runat="server" DataSourceID="ObjectDataSource1" OnRowDataBound="GridView1_RowDataBound"> <Columns> <asp:ImageField> </asp:ImageField> </Columns> </asp:GridView> <br /> <asp:ObjectDataSource ID="ObjectDataSource1" runat="server" TypeName="System.IO.Directory" SelectMethod="GetFiles"> <SelectParameters> <asp:Parameter Name="path" DefaultValue="c:\" /> </SelectParameters> </asp:ObjectDataSource> </div> </form> </body> </html>
FormView, with 2 dropdownlists
<asp:Repeater>, checkbox values and ASP.NET 2.0 List Box : help preventing duplicate items GridView EnableSortingAndPagingCallBacks Select command. GridView with objectdatasource Searching for a powerfull calendar addon difficulty setting time values in Calendar User Control used in Repeater, but no output Session sharing between ASP and ASP.NET get a filename for a bitmap in a skin |
|||||||||||||||||||||||