0

「保留中のレコードページ」があります。保留中のすべてのレコードをカウントしたいと思います。たとえば、ホームページに「(レコード数)新しい保留中のレコードがあります」を追加したいのですが、それを自分のページに追加したいと思います。Facebookのように。文字通り、それは通知メッセージのようなものです:)たとえば、ホームページに「23の新しい保留中のレコードがあります」と表示したいと思います。そのためのコードは何ですか?助けてください。

これが私のホームページのスクリーンショットです。ペイントで編集しました。表示したいラベルのテキストメッセージが表示されます。

ここに画像の説明を入力してください

保留中のレコードページのコードは次のとおりです。

<%@ Page Language="C#" Debug="true" %>
<%@ Import Namespace="System" %>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace = "System.Data.SqlClient" %>
<%@ Import Namespace= "System.Data.OleDb" %>
<title>Pending Records</title>

<head>
<style type="text/css">
.style1 {
    background-image: url('images/pending.jpg');
}
.style2 {
    margin-bottom: 0px;
}
</style>
<script type="text/javascript">
<!--
function FP_swapImgRestore() {//v1.0
 var doc=document,i; if(doc.$imgSwaps) { for(i=0;i<doc.$imgSwaps.length;i++) {
  var elm=doc.$imgSwaps[i]; if(elm) { elm.src=elm.$src; elm.$src=null; } } 
  doc.$imgSwaps=null; }
}

function FP_swapImg() {//v1.0
 var doc=document,args=arguments,elm,n; doc.$imgSwaps=new Array(); for(n=2; n<args.length;
 n+=2) { elm=FP_getObjectByID(args[n]); if(elm) { doc.$imgSwaps[doc.$imgSwaps.length]=elm;
 elm.$src=elm.src; elm.src=args[n+1]; } }
}

function FP_preloadImgs() {//v1.0
 var d=document,a=arguments; if(!d.FP_imgs) d.FP_imgs=new Array();
 for(var i=0; i<a.length; i++) { d.FP_imgs[i]=new Image; d.FP_imgs[i].src=a[i]; }
}

function FP_getObjectByID(id,o) {//v1.0
 var c,el,els,f,m,n; if(!o)o=document; if(o.getElementById) el=o.getElementById(id);
 else if(o.layers) c=o.layers; else if(o.all) el=o.all[id]; if(el) return el;
 if(o.id==id || o.name==id) return o; if(o.childNodes) c=o.childNodes; if(c)
 for(n=0; n<c.length; n++) { el=FP_getObjectByID(id,c[n]); if(el) return el; }
 f=o.forms; if(f) for(n=0; n<f.length; n++) { els=f[n].elements;
 for(m=0; m<els.length; m++){ el=FP_getObjectByID(id,els[n]); if(el) return el; } }
 return null;
}
// -->
</script>
</head>

<script runat="server" type="css">

protected void PendingRecordsGridview_PageIndexChanging(object sender, GridViewPageEventArgs e)
{
    PendingRecordsGridview.PageIndex = e.NewPageIndex;

    PendingRecordsGridview.DataBind();

}


protected void Page_Load(object sender, EventArgs e)
{

}

protected void PendingRecordsGridview_RowCommand(object sender, GridViewCommandEventArgs e)
{
    if (e.CommandName == "accept")
    {
        Session["ID"] = e.CommandArgument.ToString();
        OleDbConnection con = new OleDbConnection(ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString);
            con.Open();
            OleDbCommand cmd1 = new OleDbCommand("INSERT INTO DriversRecords (ID, FirstName, LastName, MiddleName, Address, Gender, ContactNumber, PlateNumber, Color, Brand, LiscensedNumber, [Image]) SELECT ID, FirstName, LastName, MiddleName, Address, Gender, ContactNumber, PlateNumber, Color, Brand, LiscensedNumber, [Image]  FROM PendingRecords where ID="+Session["ID"].ToString()+"", con);
            OleDbCommand cmd2 = new OleDbCommand("delete from PendingRecords where ID="+Session["ID"].ToString()+"", con);
            cmd1.ExecuteNonQuery();
            cmd2.ExecuteNonQuery();

        PendingRecordsGridview.DataBind();
    }
}

public void PendingRecordsGridview_RowDeleting(Object sender, GridViewDeleteEventArgs e)
{

}

</script>
<body onload="FP_preloadImgs(/*url*/'images/backhover.jpg')" style="margin: 0; background-color: #808080">

<form id="form1" runat="server" class="style2" style="height: 646px">

<table style="width: 1150px; height: 646px" cellspacing="0" cellpadding="0" align="center" class="style1">
    <!-- MSTableType="layout" -->
    <tr>
    <td>&nbsp;</td>
    <td></td>
    <td>&nbsp;</td>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
        <td>&nbsp;</td>

        <td style="height: 98px">&nbsp;</td>
        </tr>
    <tr>
        <td>&nbsp;</td>
        <td></td>
        <td valign="top"><a href="passwordprotect.asp">
        <img alt="" src="images/back.jpg" width="83" height="32" id="img1" onmouseout="FP_swapImgRestore()" onmouseover="FP_swapImg(1,1,/*id*/'img1',/*url*/'images/backhover.jpg')"></a></td>

        <td>&nbsp;</td>
        <td>&nbsp;</td>

        <td>&nbsp;</td>
        <td style="height: 36px">&nbsp;</td>

        </tr>
    <tr>

        <td>&nbsp;</td>
        <td></td>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
        <td style="height: 23px">&nbsp;</td>
        </tr>
    <tr>
        <td>&nbsp;</td>
        <td></td>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
        <td valign="top">
<asp:SqlDataSource runat="server" id="sd1" ProviderName="<%$ ConnectionStrings:ConnectionString.ProviderName %>" ConnectionString="<%$ ConnectionStrings:ConnectionString %>" SelectCommand="SELECT * FROM [PendingRecords]" DeleteCommand="DELETE FROM [PendingRecords] WHERE [ID] = ?" InsertCommand="INSERT INTO [PendingRecords] ([Username], [Password], [FirstName], [LastName], [MiddleName], [Address], [Gender], [ContactNumber], [PlateNumber], [Color], [Brand], [LiscensedNumber]) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)" UpdateCommand="UPDATE [PendingRecords] SET [Username] = ?, [Password] = ?, [FirstName] = ?, [LastName] = ?, [MiddleName] = ?, [Address] = ?, [Gender] = ?, [ContactNumber] = ?, [PlateNumber] = ?, [Color] = ?, [Brand] = ?, [LiscensedNumber] = ? WHERE [ID] = ?">
    <DeleteParameters>
        <asp:parameter Name="ID" Type="Int32" />
    </DeleteParameters>
    <UpdateParameters>
        <asp:parameter Name="Username" Type="String" />
        <asp:parameter Name="Password" Type="String" />
        <asp:parameter Name="FirstName" Type="String" />
        <asp:parameter Name="LastName" Type="String" />
        <asp:parameter Name="MiddleName" Type="String" />
        <asp:parameter Name="Address" Type="String" />
        <asp:parameter Name="Gender" Type="String" />
        <asp:parameter Name="ContactNumber" Type="String" />
        <asp:parameter Name="PlateNumber" Type="String" />
        <asp:parameter Name="Color" Type="String" />
        <asp:parameter Name="Brand" Type="String" />
        <asp:parameter Name="LiscensedNumber" Type="String" />
        <asp:parameter Name="ID" Type="Int32" />
    </UpdateParameters>
    <InsertParameters>
        <asp:parameter Name="Username" Type="String" />
        <asp:parameter Name="Password" Type="String" />
        <asp:parameter Name="FirstName" Type="String" />
        <asp:parameter Name="LastName" Type="String" />
        <asp:parameter Name="MiddleName" Type="String" />
        <asp:parameter Name="Address" Type="String" />
        <asp:parameter Name="Gender" Type="String" />
        <asp:parameter Name="ContactNumber" Type="String" />
        <asp:parameter Name="PlateNumber" Type="String" />
        <asp:parameter Name="Color" Type="String" />
        <asp:parameter Name="Brand" Type="String" />
        <asp:parameter Name="LiscensedNumber" Type="String" />
    </InsertParameters>
</asp:SqlDataSource>
        </td>
        <td>&nbsp;</td>
        <td style="height: 33px;">&nbsp;</td>
        </tr>
    <tr>
        <td>&nbsp;</td>
        <td></td>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
        <td>&nbsp;</td>
        <td style="height: 30px">&nbsp;</td>
    </tr>
    <tr>
        <td>&nbsp;</td>
        <td valign="top" colspan="5">
<asp:GridView OnPageIndexChanging="PendingRecordsGridview_PageIndexChanging" ID="PendingRecordsGridview" runat="server" AutoGenerateColumns="False" DataKeyNames="ID" OnRowcommand="PendingRecordsGridview_RowCommand" DataSourceID="sd1" BorderStyle="Ridge" BackColor="White" BorderColor="Black" BorderWidth="3px" CellPadding="4" Width="1089px" PageSize="2" AllowPaging="True" OnRowDeleting="PendingRecordsGridview_RowDeleting">
        <RowStyle ForeColor="#003399" HorizontalAlign="Center" />
        <Columns>
            <asp:templatefield HeaderText="Accept">
                <ItemTemplate>
                    <asp:Button CommandArgument='<%# Bind("ID") %>' ID="Button1" runat="server" CausesValidation="false" CommandName="accept" Text="Accept" />
                </ItemTemplate>
            </asp:templatefield>
            <asp:templatefield HeaderText="Ignore">
                <ItemTemplate>
                    <asp:Button ID="deleteButton" runat="server" CommandName="Delete" Text="Ignore" CausesValidation="False" OnClientClick="return confirm('Are you sure you want to cancel this request?');" />
                </ItemTemplate>
            </asp:templatefield>
            <asp:templatefield HeaderText="First Name" SortExpression="FirstName">
                <EditItemTemplate>
                    <asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("FirstName") %>'>
                    </asp:TextBox>
                </EditItemTemplate>
                <ItemTemplate>
                    <asp:Label ID="Label3" runat="server" Text='<%# Bind("FirstName") %>'>
                    </asp:Label>
                </ItemTemplate>
            </asp:templatefield>
            <asp:templatefield HeaderText="Last Name" SortExpression="LastName">
                <EditItemTemplate>
                    <asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("LastName") %>'>
                    </asp:TextBox>
                </EditItemTemplate>
                <ItemTemplate>
                    <asp:Label ID="Label4" runat="server" Text='<%# Bind("LastName") %>'>
                    </asp:Label>
                </ItemTemplate>
            </asp:templatefield>
            <asp:templatefield HeaderText="Middle Name" SortExpression="MiddleLastName">
                <EditItemTemplate>
                    <asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("MiddleName") %>'>
                    </asp:TextBox>
                </EditItemTemplate>
                <ItemTemplate>
                    <asp:Label ID="Label5" runat="server" Text='<%# Bind("MiddleName") %>'>
                    </asp:Label>
                </ItemTemplate>
            </asp:templatefield>
            <asp:templatefield HeaderText="Address" SortExpression="Address">
                <EditItemTemplate>
                    <asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("Address") %>'>
                    </asp:TextBox>
                </EditItemTemplate>
                <ItemTemplate>
                    <asp:Label ID="Label6" runat="server" Text='<%# Bind("Address") %>'>
                    </asp:Label>
                </ItemTemplate>
            </asp:templatefield>
            <asp:templatefield HeaderText="Gender" SortExpression="Gender">
                <EditItemTemplate>
                    <asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("Gender") %>'>
                    </asp:TextBox>
                </EditItemTemplate>
                <ItemTemplate>
                    <asp:Label ID="Label7" runat="server" Text='<%# Bind("Gender") %>'>
                    </asp:Label>
                </ItemTemplate>
            </asp:templatefield>
            <asp:templatefield HeaderText="Contact No." SortExpression="ContactNumber">
                <EditItemTemplate>
                    <asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("ContactNumber") %>'>
                    </asp:TextBox>
                </EditItemTemplate>
                <ItemTemplate>
                    <asp:Label ID="Label18" runat="server" Text='<%# Bind("ContactNumber") %>'>
                    </asp:Label>
                </ItemTemplate>
            </asp:templatefield>
            <asp:templatefield HeaderText="Plate No." SortExpression="PlateNumber">
                <EditItemTemplate>
                    <asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("PlateNumber") %>'>
                    </asp:TextBox>
                </EditItemTemplate>
                <ItemTemplate>
                    <asp:Label ID="Label19" runat="server" Text='<%# Bind("PlateNumber") %>'>
                    </asp:Label>
                </ItemTemplate>
            </asp:templatefield>
            <asp:templatefield HeaderText="Mobile Color" SortExpression="Color">
                <EditItemTemplate>
                    <asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("Color") %>'>
                    </asp:TextBox>
                </EditItemTemplate>
                <ItemTemplate>
                    <asp:Label ID="Label11" runat="server" Text='<%# Bind("Color") %>'>
                    </asp:Label>
                </ItemTemplate>
            </asp:templatefield>
            <asp:templatefield HeaderText="Brand" SortExpression="Brand">
                <EditItemTemplate>
                    <asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("Brand") %>'>
                    </asp:TextBox>
                </EditItemTemplate>
                <ItemTemplate>
                    <asp:Label ID="Label12" runat="server" Text='<%# Bind("Brand") %>'>
                    </asp:Label>
                </ItemTemplate>
            </asp:templatefield>
            <asp:templatefield HeaderText="Liscenced No." SortExpression="LiscensedNumber">
                <EditItemTemplate>
                    <asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("LiscensedNumber") %>'>
                    </asp:TextBox>
                </EditItemTemplate>
                <ItemTemplate>
                    <asp:Label ID="Label10" runat="server" Text='<%# Bind("LiscensedNumber") %>'>
                    </asp:Label>
                </ItemTemplate>
            </asp:templatefield>
            <asp:templatefield>
                <HeaderTemplate>
                    Image
                </HeaderTemplate>
                <ItemTemplate>
                    <img src="data:image/jpg;base64,<%# Eval("Image") != System.DBNull.Value ? Convert.ToBase64String((byte[])Eval("Image")) : string.Empty %>" alt="image" height="85" width="85" />
                </ItemTemplate>
            </asp:templatefield>
        </Columns>
        <FooterStyle BackColor="#99CCCC" ForeColor="#003399" />
        <PagerStyle HorizontalAlign="Center" BackColor="#999999" ForeColor="#003399" />
        <SelectedRowStyle BackColor="#009999" Font-Bold="True" ForeColor="#CCFF99" />
        <HeaderStyle BackColor="#A0A0A0" Font-Bold="True" ForeColor="#003399" HorizontalAlign="Center" />
        <AlternatingRowStyle BorderColor="Black" BorderWidth="3px" BorderStyle="Ridge" />
    </asp:GridView>
        </td>
        <td style="height: 333px">&nbsp;</td>
    </tr>
    <tr>
        <td style="width: 29px">&nbsp;</td>
        <td style="width: 3px"></td>
        <td style="width: 95px">&nbsp;</td>
        <td style="width: 33px">&nbsp;</td>
        <td style="width: 542px">&nbsp;</td>
        <td style="width: 422px">&nbsp;</td>
        <td style="height: 93px; width: 26px">&nbsp;</td>
    </tr>
</table>
</form>   
4

1 に答える 1

1

これは単なる疑似コードですが、コードに入れる内容に非常に近いものです。

id=Session["ID"].ToString() である pendingrecords から PendingRecordCount として count(id) を選択します。

于 2013-01-20T06:19:21.723 に答える