web 2.0

ASP.NET(vb.net) & Oracle Search Rows Record Paging/Pagination

ASP.NET(vb.net) & Oracle Search Rows Record Paging/Pagination - This is  example scripts how to use ASP.NET search rows data or record from Oracle database and view show all result in paging/pagination.

ShotDev Focus:
- ASP.NET(vb.net) & Oracle Search Rows Record Paging/Pagination

Example

AspNetOracleSearchRecordPaging.aspx

  1. <%@ Import Namespace="System.Data"%>  
  2. <%@ Import Namespace="System.Data.OracleClient"%>  
  3. <%@ Page Language="VB" %>  
  4. <script runat="server">  
  5. Dim strKeyWord As String  
  6. Sub Page_Load(sender As Object, e As EventArgs)  
  7. strKeyWord = Me.txtKeyWord.Text  
  8. End Sub  
  9.   
  10. Sub BindData()  
  11.   
  12. Dim objConn As New OracleConnection  
  13. Dim objCmd As New OracleCommand  
  14. Dim dtAdapter As New OracleDataAdapter  
  15. Dim ds As New DataSet  
  16. Dim strConnString,strSQL As String  
  17.   
  18. strConnString = "Data Source=TCDB;User Id=myuser;Password=mypassword;"  
  19. strSQL = "SELECT * FROM customer WHERE (Name like '%"& strKeyWord &"%' OR Email like '%"& strKeyWord &"%') "  
  20.   
  21. objConn.ConnectionString = strConnString  
  22. With objCmd  
  23. .Connection = objConn  
  24. .CommandText = strSQL  
  25. .CommandType = CommandType.Text  
  26. End With  
  27. dtAdapter.SelectCommand = objCmd  
  28.   
  29. dtAdapter.Fill(ds)  
  30.   
  31. '*** BindData to GridView ***'  
  32. myGridView.DataSource = ds  
  33. myGridView.DataBind()  
  34.   
  35. dtAdapter = Nothing  
  36. objConn.Close()  
  37. objConn = Nothing  
  38.   
  39. End Sub  
  40.   
  41. Sub myGridView_RowDataBound(sender As Object, e As GridViewRowEventArgs)  
  42. '*** CustomerID ***'  
  43. Dim lblCustomerID As Label = CType(e.Row.FindControl("lblCustomerID"),Label)  
  44. IF Not IsNothing(lblCustomerID) Then  
  45. lblCustomerID.Text = e.Row.DataItem("CustomerID")  
  46. End IF  
  47.   
  48. '*** Name ***'  
  49. Dim lblName As Label = CType(e.Row.FindControl("lblName"),Label)  
  50. IF Not IsNothing(lblName) Then  
  51. lblName.Text = e.Row.DataItem("Name")  
  52. End IF  
  53.   
  54. '*** Email ***'  
  55. Dim lblEmail As Label = CType(e.Row.FindControl("lblEmail"),Label)  
  56. IF Not IsNothing(lblEmail) Then  
  57. lblEmail.Text = e.Row.DataItem("Email")  
  58. End IF  
  59.   
  60. '*** CountryCode ***'  
  61. Dim lblCountryCode As Label = CType(e.Row.FindControl("lblCountryCode"),Label)  
  62. IF Not IsNothing(lblCountryCode) Then  
  63. lblCountryCode.Text = e.Row.DataItem("CountryCode")  
  64. End IF  
  65.   
  66. '*** Budget ***'  
  67. Dim lblBudget As Label = CType(e.Row.FindControl("lblBudget"),Label)  
  68. IF Not IsNothing(lblBudget) Then  
  69. lblBudget.Text = FormatNumber(e.Row.DataItem("Budget"),2)  
  70. End IF  
  71.   
  72. '*** Used ***'  
  73. Dim lblUsed As Label = CType(e.Row.FindControl("lblUsed"),Label)  
  74. IF Not IsNothing(lblUsed) Then  
  75. lblUsed.Text = FormatNumber(e.Row.DataItem("Used"),2)  
  76. End IF  
  77. End Sub  
  78.   
  79. Sub ShowPageCommand(s As Object, e As GridViewPageEventArgs)  
  80. myGridView.PageIndex = e.NewPageIndex  
  81. BindData()  
  82. End Sub  
  83.   
  84. Sub btnSearch_Click(sender As Object, e As EventArgs)  
  85. BindData()  
  86. End Sub  
  87.   
  88. </script>  
  89. <html>  
  90. <head>  
  91. <title>ShotDev.Com Tutorial</title>  
  92. </head>  
  93. <body>  
  94. <form id="form1" runat="server">  
  95. <asp:Label id="lblKeyword" runat="server" text="Keyword"></asp:Label>  
  96. <asp:TextBox id="txtKeyWord" runat="server"></asp:TextBox>  
  97. <asp:Button id="btnSearch" onclick="btnSearch_Click" runat="server" Text="Search"></asp:Button>  
  98. <br />  
  99. <br />  
  100. <asp:GridView id="myGridView" runat="server" AllowPaging="True" AutoGenerateColumns="False" onRowDataBound="myGridView_RowDataBound" OnPageIndexChanging="ShowPageCommand" PageSize="2">  
  101. <HeaderStyle backcolor="#cccccc"></HeaderStyle>  
  102. <AlternatingRowStyle backcolor="#e8e8e8"></AlternatingRowStyle>  
  103. <Columns>  
  104. <asp:TemplateField HeaderText="CustomerID">  
  105. <ItemTemplate>  
  106. <asp:Label id="lblCustomerID" runat="server"></asp:Label>  
  107. </ItemTemplate>  
  108. </asp:TemplateField>  
  109. <asp:TemplateField HeaderText="Name">  
  110. <ItemTemplate>  
  111. <asp:Label id="lblName" runat="server"></asp:Label>  
  112. </ItemTemplate>  
  113. </asp:TemplateField>  
  114. <asp:TemplateField HeaderText="Email">  
  115. <ItemTemplate>  
  116. <asp:Label id="lblEmail" runat="server"></asp:Label>  
  117. </ItemTemplate>  
  118. </asp:TemplateField>  
  119. <asp:TemplateField HeaderText="CountryCode">  
  120. <ItemTemplate>  
  121. <asp:Label id="lblCountryCode" runat="server"></asp:Label>  
  122. </ItemTemplate>  
  123. </asp:TemplateField>  
  124. <asp:TemplateField HeaderText="Budget">  
  125. <ItemTemplate>  
  126. <asp:Label id="lblBudget" runat="server"></asp:Label>  
  127. </ItemTemplate>  
  128. </asp:TemplateField>  
  129. <asp:TemplateField HeaderText="Used">  
  130. <ItemTemplate>  
  131. <asp:Label id="lblUsed" runat="server"></asp:Label>  
  132. </ItemTemplate>  
  133. </asp:TemplateField>  
  134. </Columns>  
  135. </asp:GridView>  
  136. </form>  
  137. </body>  
  138. </html>  

Screenshot

ASP.NET(vb.net) & Oracle Search Rows Record Paging/Pagination
.
.
.
Download this script.
Download

1 Star2 Stars3 Stars4 Stars5 Stars6 Stars7 Stars8 Stars9 Stars10 Stars (1 votes, average: 1.00 out of 10)
Loading ... Loading ...

Leave a Reply

You must be logged in to post a comment.