T
thebison
Hi all,
I hope someone can help with this relatively simple problem.
I am building a timesheet application using ASP.NET C# with Visual
Studio 2003.As it is only a protoype application, my database has been
made in MSDE.
My problem is to do with a DataGrid. I have successfully coded the
DataGrid so that you can Edit, Update, Cancel. However as my Update
Stored Procedure only updates certain columns I would like to make
certain columns not appear as 'editable' when the user clicks on
'Edit'. (Even though the stored procedure ignores any changes they
make, I just want the option to edit removed to avoid confusion!...)
My update method looks like this:
private void Update_DataGrid(object source,
System.Web.UI.WebControls.DataGridCommandEventArgs e)
{
System.Web.UI.WebControls.TextBox cId = new
System.Web.UI.WebControls.TextBox();
System.Web.UI.WebControls.TextBox cName = new
System.Web.UI.WebControls.TextBox();
cId = (System.Web.UI.WebControls.TextBox) e.Item.Cells[0].Controls[0];
cName = (System.Web.UI.WebControls.TextBox)
e.Item.Cells[1].Controls[0];
SqlCommand myCommand = new SqlCommand("NewUpdateDept",sqlConnection1);
myCommand.CommandType = CommandType.StoredProcedure;
myCommand.Parameters.Add(new SqlParameter("@DeptID",SqlDbType.Int,4));
myCommand.Parameters["@DeptID"].Value = cId.Text;
myCommand.Parameters.Add(new
SqlParameter("@DeptName",SqlDbType.VarChar,50));
myCommand.Parameters["@DeptName"].Value = cName.Text;
sqlConnection1.Open();
followed by the usual try-catch......let me re-iterate that this works
fine. I believe that I need to do something to make the e.Item.Cells
part not visible on the cells I wish to exclude from the Edit mode.
However I do not know what I need to do exactly?
I hope this is clear enough, thanks in advance!
Al
I hope someone can help with this relatively simple problem.
I am building a timesheet application using ASP.NET C# with Visual
Studio 2003.As it is only a protoype application, my database has been
made in MSDE.
My problem is to do with a DataGrid. I have successfully coded the
DataGrid so that you can Edit, Update, Cancel. However as my Update
Stored Procedure only updates certain columns I would like to make
certain columns not appear as 'editable' when the user clicks on
'Edit'. (Even though the stored procedure ignores any changes they
make, I just want the option to edit removed to avoid confusion!...)
My update method looks like this:
private void Update_DataGrid(object source,
System.Web.UI.WebControls.DataGridCommandEventArgs e)
{
System.Web.UI.WebControls.TextBox cId = new
System.Web.UI.WebControls.TextBox();
System.Web.UI.WebControls.TextBox cName = new
System.Web.UI.WebControls.TextBox();
cId = (System.Web.UI.WebControls.TextBox) e.Item.Cells[0].Controls[0];
cName = (System.Web.UI.WebControls.TextBox)
e.Item.Cells[1].Controls[0];
SqlCommand myCommand = new SqlCommand("NewUpdateDept",sqlConnection1);
myCommand.CommandType = CommandType.StoredProcedure;
myCommand.Parameters.Add(new SqlParameter("@DeptID",SqlDbType.Int,4));
myCommand.Parameters["@DeptID"].Value = cId.Text;
myCommand.Parameters.Add(new
SqlParameter("@DeptName",SqlDbType.VarChar,50));
myCommand.Parameters["@DeptName"].Value = cName.Text;
sqlConnection1.Open();
followed by the usual try-catch......let me re-iterate that this works
fine. I believe that I need to do something to make the e.Item.Cells
part not visible on the cells I wish to exclude from the Edit mode.
However I do not know what I need to do exactly?
I hope this is clear enough, thanks in advance!
Al