Solved

ado.net datagrid update timestamp query

Posted on 2004-08-29
2
328 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 500 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

Enroll in May's Course of the Month

May’s Course of the Month is now available! Experts Exchange’s Premium Members and Team Accounts have access to a complimentary course each month as part of their membership—an extra way to increase training and boost professional development.

Question has a verified solution.

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

Extention Methods in C# 3.0 by Ivo Stoykov C# 3.0 offers extension methods. They allow extending existing classes without changing the class's source code or relying on inheritance. These are static methods invoked as instance method. This…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…
This video shows how to use Hyena, from SystemTools Software, to update 100 user accounts from an external text file. View in 1080p for best video quality.

734 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