Solved

ado.net datagrid update timestamp query

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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Simple Injector with Web Service 4 55
Hey Audio! 9 45
length of the password hash sha1:64000 to set sql field property. 13 67
itextsharp with c# 3 10
This article describes a simple method to resize a control at runtime.  It includes ready-to-use source code and a complete sample demonstration application.  We'll also talk about C# Extension Methods. Introduction In one of my applications…
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…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

820 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