Sunday 30 June 2013

show Reports of User Registered on Particular Date

show Reports of User Registered on Particular Date

.aspx Page Code:

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Report.aspx.cs" Inherits="Report" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
   <div>
   <table class="style1" align="center">
                <tr>
                    <td bgcolor="#99CCFF" colspan="2" style="text-align: center">
                        S<b>how Reports on User Registered </b></td>
                </tr>
                <tr>
                    <td>
                        <asp:Label ID="lblstartdate" runat="server" Text="Registration Date"></asp:Label>
                    </td>
                    <td>
                        <asp:TextBox ID="txtstartingdate" runat="server"></asp:TextBox>
                        <br />
                        <asp:Calendar ID="Calendar1" runat="server"
                            onselectionchanged="Calendar1_SelectionChanged"></asp:Calendar>
                    </td>
                </tr>
                <%--<tr>
                    <td>
                        <asp:Label ID="lblendingdate" runat="server" Text="Ending Date"></asp:Label>
                    </td>
                    <td>
                        <asp:TextBox ID="txtendingdate" runat="server"></asp:TextBox>
                    </td>
                </tr>--%>
                <tr>
                    <td>
                        &nbsp;</td>
                    <td>
                        <asp:Button ID="btnfilter" runat="server" Text="Show  Registered Users" Width="166px"
                            onclick="btnfilter_Click" />
                    </td>
                </tr>
            </table>
</div>

    <asp:GridView ID="GVMec" runat="server">
    </asp:GridView>

    </form>
</body>

</html>

===============================================================

.CS CODE:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;
using System.Drawing;
using System.Configuration;
using System.Data;

public partial class Report : System.Web.UI.Page
{
    string Str = ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString;
    protected void Page_Load(object sender, EventArgs e)
    {

    }

    protected void btnfilter_Click(object sender, EventArgs e)
    {
       
          SqlConnection conn= new SqlConnection(Str);
         
                conn.Open();
                SqlCommand cmd = new SqlCommand();
                // cmd.Parameters.Add(new SqlParameter("@Date1", SqlDbType.DateTime)).Value = txtstartingdate ;
                SqlDataAdapter sda = new SqlDataAdapter("Select * From Tbl_User_Registration Where U_Rdate= '" + txtstartingdate.Text + "' ", conn);
                SqlCommandBuilder scb = new SqlCommandBuilder(sda);
                //Create a DataTable to hold the query results.
                DataTable dTable = new DataTable();
                //Fill the DataTable.
                sda.Fill(dTable);
                if (dTable.Rows.Count > 0)
                {
                    GVMec.DataSource = dTable;
                    GVMec.DataBind();
                }
                else
                {
                    Response.Write("<script>alert('No Recodrd Found')</script>");
                }
 

               
               
       
                   
               }
    protected void Calendar1_SelectionChanged(object sender, EventArgs e)
    {
        txtstartingdate.Text = Calendar1.SelectedDate.ToString("dd/MM/yyyy");
     
    }

}



No comments:

Post a Comment