Hello forum,
I implemented gridview paging using stored procedure. Here is my HTML, CSS, SQL and C#
HTML
<asp:Button ID="Button1" runat="server" Text="New Item" CssClass="btn btn-primary" BackColor="SteelBlue" />
<br />
<div class="grid-corner" style="width: 95%; background-color: white;">
<div style="width:100%; background-color:#A0A0A0;font-family:Verdana; font-size:medium;">
<label>All Invoice List</label>
</div>
<br />
<br />
<asp:GridView ID="GridView1" runat="server" GridLines="None" AllowPaging="true" HeaderStyle-ForeColor="#00003D"
HeaderStyle-Font-Bold="true" AutoGenerateColumns="false" class="table" Width="100%">
<Columns>
<asp:BoundField DataField="email" HeaderText="User Email" />
<asp:BoundField DataField="Name" HeaderText="File Name" />
<asp:BoundField DataField="CreatedDate" HeaderText="Date Created" />
</Columns>
</asp:GridView>
<div style="float: right;">
Page
<asp:Label ID="lblPageIndex" runat="server" Text="Label" />
of
<asp:Label ID="lblTotalPage" runat="server" />
(<asp:Label ID="lblTotal" runat="server" />
items)
<div class="dvPager">
<asp:Repeater ID="rptPager" runat="server">
<ItemTemplate>
<asp:LinkButton ID="lnkPage" runat="server" Text='<%#Eval("Text") %>' CommandArgument='<%# Eval("Value") %>'
CssClass='<%# Convert.ToBoolean(Eval("Enabled")) ? "page_enabled" : "page_disabled" %>'
OnClick="Page_Changed" OnClientClick='<%# !Convert.ToBoolean(Eval("Enabled")) ? "return false;" : "" %>'></asp:LinkButton>
</ItemTemplate>
</asp:Repeater>
</div>
</div>
<br />
<br />
</div>
SQL
CREATE PROCEDURE [dbo].[Dataregister]
@PageIndex INT
,@PageSize INT
,@RecordCount INT OUT
AS
BEGIN
SELECT ROW_NUMBER() OVER(ORDER BY email) RowNumber
,email
,Organization
,Name
,CreatedDate
INTO #Temp
FROM CardTbl
SELECT @RecordCount = COUNT(*) FROM #Temp
SELECT * FROM #Temp
WHERE (RowNumber BETWEEN ((@PageIndex-1) * @PageSize) + 1 AND (@PageIndex * @PageSize)) OR @PageIndex = - 1
DROP TABLE #Temp
END
RETURN 0
The issue I now have is that I don’t want to display one records from one table; I want to display records from different tables and on different forms. Example, if I have table1, table2 and table3; and I also have webform1, webform2 and webform3. Each page will display records from tables separately (webform1 will display records from table1, webform2 will display table2……).
But since I’m selecting data from the table name in the stored procedure (as shown below), and I don’t know how to use another SQL to select data from another table.
Please how can I select data from multiple tables based on the user who logged in, and link them to each web form for display? Because it is not the same as having an SQL command to select data WHERE “column name” = @parameter.