Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

ado.net datagrid update timestamp query

Posted on 2004-08-29
2
Medium Priority
?
331 Views
Last Modified: 2012-08-13
Say I have some code like below. How would I be able to get focus of the current update row and input a timestamp within a column without making the current row's date column editable but input a current timestamp automatically?


string Inv, dateT;
string Key = DGrid.DataKeys[e.Item.ItemIndex].ToString();
TextBox box;
                  box = (TextBox)(e.Item.Cells[1].Controls[0]);
                  Inv=box.Text;

                  // Gets the value the TextBox control in the fourth column
                  box = (TextBox)(e.Item.Cells[8].Controls[0]);
                  dateT= box.Text;



                  string Sq;
                  DateTime ToDa = DateTime.Now.Date.ToUniversalTime();
            
ToDa.ToString();
                  Sq = "Update [Waveplate]" +
                        "set Inventory_Status=@Inventory_Status, Reserve_Timestamp = "+ToDa+
                        "where Part_Key =@Part_Key";

                  SqlCommand SCom = new SqlCommand(Sq, Conn);
                  //SqlParameterCollection CSql = SCom.Parameters;

                  SCom.Parameters.Add("@Part_Key", SqlDbType.Char);
                  SCom.Parameters["@Part_Key"].Value=Key;


                  SCom.Parameters.Add("@Inventory_Status", SqlDbType.Char);
                  SCom.Parameters["@Inventory_Status"].Value=Inv;


                  SCom.Parameters.Add("@Reserve_Time", SqlDbType.DateTime);
                  SCom.Parameters["@Reserve_Time"].Value=ToDa;


                SCom.Parameters["@Part_Key"].Value = DGrid.DataKeys[(int)e.Item.ItemIndex];
            SCom.Connection.Open();
0
Comment
Question by:devlins
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 10

Accepted Solution

by:
123654789987 earned 1500 total points
ID: 11928728
If u databind a datagrid to a datasource (Eq:a datatable) then if u update the value of the Timestamp column in the datatable then automatically the datagrid should be refreshed with the new data

datagrid.datasource = dataTable;
datagrid.databind();

dataTable["Timestamp"] = DateTime.Now.Date.ToUniversalTime();
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Ready to improve network connectivity? Watch this webinar to learn how SD-WANs and a one-click instant connect tool can boost provisions, deployment, and management of your cloud connection.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: Najam
Having new technologies does not mean they will completely replace old components.  Recently I had to create WCF that will be called by VB6 component.  Here I will describe what steps one should follow while doing so, please feel free to post any qu…
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…

661 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question