D
DC
Dear ASP.Net Experts,
In ASP, I can write something like this:
<table>
<tr>
<th align=left>ID</th>
<th align=left>Product Name</th>
<th align=left>Price</th>
</tr>
<%
....
sSQL = "SELECT productID, productName, price ..... "
.....
objCmd.CommandText = sSQL
set rs = objCmd.Execute
if rs.BOF and rs.EOF then
%>
<tr>
<td align=center>No records</td>
</tr>
<%
else
do while not rs.EOF
%>
<tr onMouseOver='this.style.backgroundColor='yellow'
onMouseOut='this.style.backgroundColor='white'
onClick="self.location='view_product.asp?id=<%=rs("productID")%>'">
<td align=left><%=rs("productID")%></td>
<td align=left><%=rs("productName")%></td>
<td align=left><%=FormatCurrency(rs("price"), 2)%></td>
</tr>
<%
rs.MoveNext
loop
%>
<tr>
<td align=left>Total Record: <%=rs.RecordCount%></td>
<td> </td>
<td><!-- #include file=paging.inc --></td>
</tr>
<%
end if
rs.Close
set rs = nothing
%>
</table>
How do I implement those in datagrid (ASP.NET), in a sense that it has to
meet requirements:
1. If no records found, display: "No Records" instead of displaying no rows
at all
2. On Click on any rows, redirect to specific aspx page
3. Each time OnMouseOver and OnMouseOut, the color of the row will be
changed
4. In footer, on the left side there's indicator on the total record, while
on the right side will display the paging number
Here is my datagrid snippet:
....
<form name="frmList" runat="server">
<aspataGrid id="dgList" runat="server" Width="100%" CssClass="BodyText"
AllowPaging="True" AllowSorting="True"
AutoGenerateColumns="False" PageSize="20" BorderColor="#CC9966"
BorderStyle="None" BorderWidth="1px"
BackColor="White" CellPadding="4" HorizontalAlign="Right"<SelectedItemStyle Font-Bold="True" ForeColor="#663399"
BackColor="#FFCC66"></SelectedItemStyle>
<ItemStyle ForeColor="#330099" BackColor="White"></ItemStyle>
<HeaderStyle Font-Bold="True" ForeColor="#FFFFCC" CssClass="headerList"
BackColor="#990000"></HeaderStyle>
<FooterStyle HorizontalAlign="Right" ForeColor="#330099"
CssClass="BodyText" BackColor="#FFFFCC"></FooterStyle>
<Columns>
<asp:BoundColumn DataField="productID" SortExpression="productID"
HeaderText="ID"></asp:BoundColumn>
<asp:BoundColumn DataField="productName"
SortExpression="productName" HeaderText="Product Name"></asp:BoundColumn>
<asp:BoundColumn DataField="price" SortExpression="price"
HeaderText="Price"></asp:BoundColumn>
<asp:EditCommandColumn EditText="View" HeaderText="Action"
ItemStyle-Width="40px"></asp:EditCommandColumn>
</Columns>
<PagerStyle HorizontalAlign="Right" PageButtonCount="5"
ForeColor="#330099" BackColor="#FFFFCC" CssClass="bodytext"
Mode="NumericPages"></PagerStyle>
</aspataGrid>
</form>
....
Thanks in advance for your help.
- DC
In ASP, I can write something like this:
<table>
<tr>
<th align=left>ID</th>
<th align=left>Product Name</th>
<th align=left>Price</th>
</tr>
<%
....
sSQL = "SELECT productID, productName, price ..... "
.....
objCmd.CommandText = sSQL
set rs = objCmd.Execute
if rs.BOF and rs.EOF then
%>
<tr>
<td align=center>No records</td>
</tr>
<%
else
do while not rs.EOF
%>
<tr onMouseOver='this.style.backgroundColor='yellow'
onMouseOut='this.style.backgroundColor='white'
onClick="self.location='view_product.asp?id=<%=rs("productID")%>'">
<td align=left><%=rs("productID")%></td>
<td align=left><%=rs("productName")%></td>
<td align=left><%=FormatCurrency(rs("price"), 2)%></td>
</tr>
<%
rs.MoveNext
loop
%>
<tr>
<td align=left>Total Record: <%=rs.RecordCount%></td>
<td> </td>
<td><!-- #include file=paging.inc --></td>
</tr>
<%
end if
rs.Close
set rs = nothing
%>
</table>
How do I implement those in datagrid (ASP.NET), in a sense that it has to
meet requirements:
1. If no records found, display: "No Records" instead of displaying no rows
at all
2. On Click on any rows, redirect to specific aspx page
3. Each time OnMouseOver and OnMouseOut, the color of the row will be
changed
4. In footer, on the left side there's indicator on the total record, while
on the right side will display the paging number
Here is my datagrid snippet:
....
<form name="frmList" runat="server">
<aspataGrid id="dgList" runat="server" Width="100%" CssClass="BodyText"
AllowPaging="True" AllowSorting="True"
AutoGenerateColumns="False" PageSize="20" BorderColor="#CC9966"
BorderStyle="None" BorderWidth="1px"
BackColor="White" CellPadding="4" HorizontalAlign="Right"<SelectedItemStyle Font-Bold="True" ForeColor="#663399"
BackColor="#FFCC66"></SelectedItemStyle>
<ItemStyle ForeColor="#330099" BackColor="White"></ItemStyle>
<HeaderStyle Font-Bold="True" ForeColor="#FFFFCC" CssClass="headerList"
BackColor="#990000"></HeaderStyle>
<FooterStyle HorizontalAlign="Right" ForeColor="#330099"
CssClass="BodyText" BackColor="#FFFFCC"></FooterStyle>
<Columns>
<asp:BoundColumn DataField="productID" SortExpression="productID"
HeaderText="ID"></asp:BoundColumn>
<asp:BoundColumn DataField="productName"
SortExpression="productName" HeaderText="Product Name"></asp:BoundColumn>
<asp:BoundColumn DataField="price" SortExpression="price"
HeaderText="Price"></asp:BoundColumn>
<asp:EditCommandColumn EditText="View" HeaderText="Action"
ItemStyle-Width="40px"></asp:EditCommandColumn>
</Columns>
<PagerStyle HorizontalAlign="Right" PageButtonCount="5"
ForeColor="#330099" BackColor="#FFFFCC" CssClass="bodytext"
Mode="NumericPages"></PagerStyle>
</aspataGrid>
</form>
....
Thanks in advance for your help.
- DC