web 2.0

ASP.NET(vb.net) & DetailsView - AlternatingRowStyle

ASP.NET(vb.net) & DetailsView - AlternatingRowStyle Example scripts how to use DetailsView control in asp.net , The AlternatingRowStyle gets a reference to the TableItemStyle object that allows you to set the appearance of the alternating data rows in a DetailsView control.

ShotDev Focus:
- ASP.NET(vb.net) & DetailsView - AlternatingRowStyle

Example

DetailsViewAlternatingRow.aspx

  1.  <%@ Import Namespace="System.Data"%>  
  2. <%@ Import Namespace="System.Data.OleDb"%>  
  3. <%@ Page Language="VB" %>  
  4. <script runat="server">  
  5. Dim objConn As OleDbConnection  
  6. Dim objCmd As OleDbCommand  
  7. Dim strCusID As String = "C001"  '*** Request.QueryString("CusID") ***'  
  8.   
  9. Sub Page_Load(sender As Object, e As EventArgs)  
  10. Dim strConnString As String  
  11. strConnString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source="&Server.MapPath("database/mydatabase.mdb")&";"  
  12. objConn = New OleDbConnection(strConnString)  
  13. objConn.Open()  
  14.   
  15. BindData()  
  16. End Sub  
  17.   
  18. Sub BindData()  
  19. Dim strSQL As String  
  20. strSQL = "SELECT * FROM customer WHERE CustomerID = '"& strCusID &"' "  
  21.   
  22. Dim dtReader As OleDbDataReader  
  23. objCmd = New OleDbCommand(strSQL, objConn)  
  24. dtReader = objCmd.ExecuteReader()  
  25.   
  26. '*** BindData to DetailsView ***'  
  27. myDetailsView.DataSource = dtReader  
  28. myDetailsView.DataBind()  
  29.   
  30. dtReader.Close()  
  31. dtReader = Nothing  
  32.   
  33. End Sub  
  34.   
  35. Sub Page_UnLoad()  
  36. objConn.Close()  
  37. objConn = Nothing  
  38. End Sub  
  39. </script>  
  40. <html>  
  41. <head>  
  42. <title>ShotDev.Com Tutorial</title>  
  43. </head>  
  44. <body>  
  45. <form id="form1" runat="server">  
  46. <asp:DetailsView id="myDetailsView" runat="server"  
  47. BackColor="LightGoldenrodYellow"  
  48. BorderColor="Tan" BorderWidth="1px"  
  49. CellPadding="2" ForeColor="Black" GridLines="None">  
  50. <FooterStyle BackColor="Tan" />  
  51. <PagerStyle BackColor="PaleGoldenrod" ForeColor="DarkSlateBlue" HorizontalAlign="Center" />  
  52. <HeaderStyle BackColor="Tan" Font-Bold="True" />  
  53. <EditRowStyle BackColor="DarkSlateBlue" ForeColor="GhostWhite" />  
  54. <AlternatingRowStyle BackColor="PaleGoldenrod" />  
  55. </asp:DetailsView>  
  56. </form>  
  57. </body>  
  58. </html>  

Create a asp.net file and save to path root-path/dotnet/

Run
http://localhost/dotnet/DetailsViewAlternatingRow.aspx

Screenshot

ASP.NET(vb.net) & DetailsView - AlternatingRowStyle
.
.
.

Download this script.
Download

1 Star2 Stars3 Stars4 Stars5 Stars6 Stars7 Stars8 Stars9 Stars10 Stars (No Ratings Yet)
Loading ... Loading ...

One Response to “ASP.NET(vb.net) & DetailsView - AlternatingRowStyle”

  1. 1arterial…

Leave a Reply

You must be logged in to post a comment.