• If you are citizen of an European Union member nation, you may not use this service unless you are at least 16 years old.

  • Buried in cloud files? We can help with Spring cleaning!

    Whether you use Dropbox, Drive, G-Suite, OneDrive, Gmail, Slack, Notion, or all of the above, Dokkio will organize your files for you. Try Dokkio (from the makers of PBworks) for free today.

  • Dokkio (from the makers of PBworks) was #2 on Product Hunt! Check out what people are saying by clicking here.


Lecture - How To - Create Forms that Update

Page history last edited by Dr. Ron Eaglin 9 years, 11 months ago


Create Forms that Update




Lecture - Form Objects - Buttons

Lecture - Form Objects - GridView

Adding Item Templates to Datagrid

How to Pass Variables Between Web Forms





This video demonstrates how to add a template column to a GridView, pulls a value from the GridView and adds it into the Session. This is then passed to a second form that uses the value to pull data from the database and also go into Update Mode.






Reference Materials


In the Gridview -

Use of ComandName - http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.commandeventargs.commandname.aspx 

Use of CommandArgument - http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.commandeventargs.commandargument 

Use of OnRowCommand - http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.gridview.onrowcommand%28v=vs.90%29.aspx 

Creating a Template Column - http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.templatefield.itemtemplate.aspx 


DatabaseHelper Class (as used in this example)

    public class DatabaseHelper
        #region "Static Methods"
        public static string connectionString()
            return DatabaseHelper.connectionString("TraumaFlowConnectionString");
        public static string connectionString(string connName)
            System.Configuration.Configuration rootWeb = System.Web.Configuration.WebConfigurationManager.OpenWebConfiguration("/TraumaFlow");
            System.Configuration.ConnectionStringSettings connstr;
            if (rootWeb.ConnectionStrings.ConnectionStrings.Count > 0)
                connstr = rootWeb.ConnectionStrings.ConnectionStrings[connName];
                return connstr.ConnectionString;
            return String.Empty;
        public static void fillTextBox(TextBox tb, string XMLName, int TraumaFormID)
            tb.Text = getValue(XMLName, TraumaFormID);
        public static string getValue(string XMLName, int TraumaFormID)
            if (XMLName == "PatientReportedName") return DatabaseHelper.getPatientName(TraumaFormID);
            string sql = "SELECT Value FROM view_TextMedicalData ";
            sql += "WHERE XMLName = '" + XMLName +"'";
            sql += " AND id = " + Convert.ToString(TraumaFormID);
            return DatabaseHelper.executeSqlReturnString(sql);
        public static string getPatientName(int TraumaFormID)
            string sql = "SELECT name FROM TraumaForm WHERE id = '" + TraumaFormID.ToString() + "'";
            return DatabaseHelper.executeSqlReturnString(sql);
        public static int getCodeID(string XMLName, int TraumaFormID)
            string sql = "SELECT CodeID FROM view_CodedMedicalData ";
            sql += "WHERE XMLName = '" + XMLName + "'";
            sql += " AND id = " + Convert.ToString(TraumaFormID);
            return Convert.ToInt32(DatabaseHelper.executeSqlReturnString(sql));
        public static string executeSqlReturnString(string sql)
            // Should be the first element in the DataTable
            DataTable dt = DatabaseHelper.executeSqlReturnDataTable(sql);
            if (dt.Rows.Count >= 1)
                return Convert.ToString(dt.Rows[0][0]);
                return String.Empty;
        public static DataTable executeSqlReturnDataTable(string sql)
            SqlConnection connection = new SqlConnection(DatabaseHelper.connectionString());
            SqlCommand command = new SqlCommand(sql, connection);
            SqlDataAdapter a = new SqlDataAdapter(command);
            DataTable dt = new DataTable();
            return dt;

Screen Captures



Additional Information





COP 4834 Lectures Page

Comments (0)

You don't have permission to comment on this page.