Nevron Gauge for SharePoint
Skip Navigation Links
C# Corner Home
Forum Home
Latest 50
Unanswered
Win Prizes
All Time Leaders
Jump to CategoryExpand Jump to Category
Login 
    Welcome Guest!
 Search Forum For :  
X
 Login
Please login to submit a new post, reply and edit exiting posts, see user profiles, and access more features. If you are not a registered member, Register here.
User Id / Email:
Password:  
Forgot Password | Forgot UserName
   Home » C# Language » how to show system_date in changingMode in formview....
       
Author Reply
avijit chatterjee
posted 16 posts
since Dec 29, 2009 
from

how to show system_date in changingMode in formview....

  Posted on: 10 Sep 2010       
Hi...
i am having insertpage.aspx where i am fetching systemdate but when i am changingMode in for data Insert, systemdate not showing that time and srno also and same as EditMode also.For that reason i can't insert value because its taking null values...... I am sending codebehind code .....please help me out.....
/*********************************************************/

using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using VehicleApp.library;

public partial class InsertPage : System.Web.UI.Page
{
    library lib = new library();
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            BindFormView();
            Label mydate = (Label)VehicleFormView.Row.FindControl("dateLabel");
            mydate.Text = DateTime.Now.Date.ToShortDateString();
        }

    }
    private void BindFormView()
    {
        if (Session["strTemp"] != null)
        {
            VehicleFormView.DataSource = Session["strTemp"] as DataTable;
            VehicleFormView.DataBind();
        }
        else
        {
            VehicleFormView.DataSource = GetVehicledetail();
            VehicleFormView.DataBind();
        }
    }

    public DataTable GetVehicledetail()
    {
        library lib = new library();

        DataSet MyDataSet = new DataSet();
        DataTable dtable = new DataTable("strTemp");
        dtable.Columns.Add("srno", typeof(string));
        dtable.Columns.Add("cur_date", typeof(string));
        dtable.Columns.Add("official", typeof(string));
        dtable.Columns.Add("private", typeof(string));
        dtable.Columns.Add("empcode", typeof(string));
        dtable.Columns.Add("name", typeof(string));
        dtable.Columns.Add("designation", typeof(string));
        dtable.Columns.Add("department", typeof(string));
        dtable.Columns.Add("vehicle_reqd_on", typeof(string));
        dtable.Columns.Add("from_hours", typeof(string));
        dtable.Columns.Add("to_hours", typeof(string));
        dtable.Columns.Add("visit_place", typeof(string));
        dtable.Columns.Add("vehicle_rpt_person", typeof(string));
        dtable.Columns.Add("vehicle_rpt_location", typeof(string));
        dtable.Columns.Add("purpose", typeof(string));
        dtable.Columns.Add("vehicle_no", typeof(string));
        dtable.Columns.Add("driver_name", typeof(string));
        dtable.Columns.Add("departure_time", typeof(string));
        dtable.Columns.Add("departure_kms_reading", typeof(string));
        dtable.Columns.Add("arrival_time", typeof(string));
        dtable.Columns.Add("arrival_kms_reading", typeof(string));

        DataColumn[] dc = new DataColumn[1];
        dc[0] = dtable.Columns["srno"];

        dtable.PrimaryKey = dc;
        dtable.Columns["srno"].AutoIncrement = true;
        dtable.Columns["srno"].AutoIncrementSeed = 1;


        DataRow dr = dtable.NewRow();
         for (int i = 1; i <= 19; i++)
            {
                dr[i] = "";
            }
            dtable.Rows.Add(dr);
            MyDataSet.Tables.Add(dtable);
            VehicleFormView.DataSource = MyDataSet;
            VehicleFormView.DataBind();
            Session["strTemp"] = dtable;
            return dtable;
            
    }

    protected void VehicleFormView_PageIndexChanging(object sender, FormViewPageEventArgs e)
    {

        VehicleFormView.PageIndex = e.NewPageIndex;
        BindFormView();
    }

    protected void VehicleFormView_ModeChanging(object sender, FormViewModeEventArgs e)
    {
        if (e.NewMode.ToString() == "Edit")
        {
            VehicleFormView.ChangeMode(e.NewMode);
        }
        else if (e.NewMode.ToString() == "Insert")
        {
            VehicleFormView.ChangeMode(e.NewMode);
        }
        else

            VehicleFormView.ChangeMode(e.NewMode);

        BindFormView();
    }

    protected void VehicleFormView_ItemInserting(object sender, FormViewInsertEventArgs e)
    {
        library lib = new library();
        DataTable dt = Session["strTemp"] as DataTable;
        DataRow dr = dt.NewRow();


        dr[1] = ((TextBox)VehicleFormView.FindControl("cur_date")).Text.Trim();
        dr[2] = ((TextBox)VehicleFormView.FindControl("official")).Text.Trim();
        dr[3] = ((TextBox)VehicleFormView.FindControl("private")).Text.Trim();
        dr[4] = ((TextBox)VehicleFormView.FindControl("empcode")).Text.Trim();
        dr[5] = ((TextBox)VehicleFormView.FindControl("name")).Text.Trim();
        dr[6] = ((TextBox)VehicleFormView.FindControl("designation")).Text.Trim();
        dr[7] = ((TextBox)VehicleFormView.FindControl("department")).Text.Trim();
        dr[8] = ((TextBox)VehicleFormView.FindControl("vehicle_reqd_on")).Text.Trim();
        dr[9] = ((TextBox)VehicleFormView.FindControl("from_hours")).Text.Trim();
        dr[10] = ((TextBox)VehicleFormView.FindControl("to_hours")).Text.Trim();
        dr[11] = ((TextBox)VehicleFormView.FindControl("visit_place")).Text.Trim();
        dr[12] = ((TextBox)VehicleFormView.FindControl("vehicle_rpt_person")).Text.Trim();
        dr[13] = ((TextBox)VehicleFormView.FindControl("vehicle_rpt_location")).Text.Trim();
        dr[14] = ((TextBox)VehicleFormView.FindControl("purpose")).Text.Trim();
        dr[15] = ((TextBox)VehicleFormView.FindControl("vehicle_no")).Text.Trim();
        dr[16] = ((TextBox)VehicleFormView.FindControl("driver_name")).Text.Trim();
        dr[17] = ((TextBox)VehicleFormView.FindControl("departure_time")).Text.Trim();
        dr[18] = ((TextBox)VehicleFormView.FindControl("departure_kms_reading")).Text.Trim();
        dr[19] = ((TextBox)VehicleFormView.FindControl("arrival_time")).Text.Trim();
        dr[20] = ((TextBox)VehicleFormView.FindControl("arrival_kms_reading")).Text.Trim();
        
        
        dt.Rows.Add(dr);
        Session["strTemp"] = dt;
        VehicleFormView.ChangeMode(FormViewMode.ReadOnly);
        BindFormView();

    }

    protected void VehicleFormView_ItemUpdating(object sender, FormViewUpdateEventArgs e)
    {
        string srno = VehicleFormView.DataKey.Value.ToString();
        DataTable dt = Session["strTemp"] as DataTable;
        DataRow dr;
        dr = dt.NewRow();
        dr = dt.Rows.Find(srno);


        dr[1] = ((TextBox)VehicleFormView.FindControl("cur_date")).Text;
        dr[2] = ((TextBox)VehicleFormView.FindControl("official")).Text;
        dr[3] = ((TextBox)VehicleFormView.FindControl("private")).Text;
        dr[4] = ((TextBox)VehicleFormView.FindControl("empcode")).Text;
        dr[5] = ((TextBox)VehicleFormView.FindControl("name")).Text;
        dr[6] = ((TextBox)VehicleFormView.FindControl("designation")).Text;
        dr[7] = ((TextBox)VehicleFormView.FindControl("department")).Text;
        dr[8] = ((TextBox)VehicleFormView.FindControl("vehicle_reqd_on")).Text;
        dr[9] = ((TextBox)VehicleFormView.FindControl("from_hours")).Text;
        dr[10] = ((TextBox)VehicleFormView.FindControl("to_hours")).Text;
        dr[11] = ((TextBox)VehicleFormView.FindControl("visit_place")).Text;
        dr[12] = ((TextBox)VehicleFormView.FindControl("vehicle_rpt_person")).Text;
        dr[13] = ((TextBox)VehicleFormView.FindControl("vehicle_rpt_location")).Text;
        dr[14] = ((TextBox)VehicleFormView.FindControl("purpose")).Text;
        dr[15] = ((TextBox)VehicleFormView.FindControl("vehicle_no")).Text;
        dr[16] = ((TextBox)VehicleFormView.FindControl("driver_name")).Text;
        dr[17] = ((TextBox)VehicleFormView.FindControl("departure_time")).Text;
        dr[18] = ((TextBox)VehicleFormView.FindControl("departure_kms_reading")).Text;
        dr[19] = ((TextBox)VehicleFormView.FindControl("arrival_time")).Text;
        dr[20] = ((TextBox)VehicleFormView.FindControl("arrival_kms_reading")).Text;
        dt.GetChanges();
        Session["strTemp"] = dt;
        VehicleFormView.ChangeMode(FormViewMode.ReadOnly);
        BindFormView();

    }

    protected void VehicleFormView_ItemDeleting(object sender, FormViewDeleteEventArgs e)
    {
        string srno = VehicleFormView.DataKey.Value.ToString();
        DataTable dt = Session["strTemp"] as DataTable;
        DataRow dr;
        dr = dt.NewRow();
        dt.Rows.Find(srno).Delete();
        dt.GetChanges();
        Session["strTemp"] = dt;
        VehicleFormView.ChangeMode(FormViewMode.ReadOnly);
        BindFormView();
    }

Please check the Insert,update and  function  not working properly. whatt exactly i am doing is i am working on 3-tier architecture where creating provider for database,library for presentation and calling Library in .aspxPage.

please someone help me.....please


/********************************************************/
 

       
Team Foundation Server Hosting
Dynamic PDF
ceTE software specializes in components for dynamic PDF generation and manipulation. The DynamicPDF™ product line allows you to dynamically generate PDF documents, merge PDF documents and new content to existing PDF documents from within your applications. Visit DynamicPDF here
Introducing MaxV - one click. infinite control. Hyper-V Hosting from MaximumASP.
Finally – a virtual platform that delivers next-generation Windows Server 2008 Hyper-V virtualization technology from a managed hosting partner you can truly depend on. Visit www.maximumasp.com/max for a FREE 30 day trial. Hurry offer ends soon. Climb aboard the MaxV platform and take advantage of High Availability, Intelligent Monitoring, Recurrent Backups, and Scalability – with no hassle or hidden fees. As a managed hosting partner focused solely on Microsoft technologies since 2000, MaximumASP is uniquely qualified to provide the superior support that our business is built on. Unparalleled expertise with Microsoft technologies lead to working directly with Microsoft as first to offer IIS 7 and SQL 2008 betas in a hosted environment; partnering in the Go Live Program for Hyper-V; and product co-launches built on WS 2008 with Hyper-V technology.
Nevron Chart for .NET 2010.1 Now Available
The leading .NET charting control now features PDF, Flash and Silverlight export, visualization of large datasets and more. Deliver true charting functionality to your BI, Scorecard, Presentation or Scientific apps. Download evaluation now.
ASP.NET 4 Hosting
Get 2 Months Free of ASP.NET Hosting for Only $4.95/month! Receive FREE MS SQL and MySQL Databases Including ASP.NET 4/3.5, MVC 3.0, Silverlight 4, Windows 2008/IIS 7.0 Plus FREE IIS 7 Modules. Host UNLIMITED ASP.NET Web Sites - Click Here!
6 Months Free & No Setup Fees ASP.NET Hosting!
 Hosted by MaximumASP  |  Found a broken link?  |  Contact Us  |  Terms & conditions  |  Privacy Policy  |  Site Map  |  Advertise with us
Current Version: 5.2011.3.12
 © 1999 - 2012  Mindcracker LLC. All Rights Reserved