i just started a crash course in c# web applicaitons
is it possible to use stored procedures in c#.net web applications?
and i have a problem updating the datagrid on a wep app
im using VS 2003 frontend
and access 2003 backend
the problem line is
"string key = DataGrid1.DataKeys[e.Item.ItemIndex].ToString();"
the error is
"Index was out of range. Must be non-negative and less than the size of the collection. Parameter name: index "
im still a novice in programming especially c#
so if you could help me understand this i would be much appreciative
![]()
Code:private void DataGrid1_UpdateCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e) {string sc; sc = "SELECT tblTasks.strTask, tblTasks.memInstructions, tblTasks.dtmDuedate, tblTasks.strContact, tblTasks.strLocation FROM tblTasks"; DataSet ds = new DataSet(); System.Data.OleDb.OleDbConnection odc = new OleDbConnection("Provider=Microsoft.JET.OLEDB.4.0;data source=Tasks.mdb"); System.Data.OleDb.OleDbDataAdapter da = new OleDbDataAdapter(sc, odc); System.Data.OleDb.OleDbCommandBuilder cb = new OleDbCommandBuilder(); DataGrid1.DataSource = ds.Tables["tblTasks"]; // // string strTask, memInstructions, dtmDuedate, strContact, strLocation; string key = DataGrid1.DataKeys[e.Item.ItemIndex].ToString(); TextBox tb; tb = (TextBox)(e.Item.Cells[2].Controls[0]); strTask = tb.Text; tb = (TextBox)(e.Item.Cells[3].Controls[0]); memInstructions = tb.Text; tb = (TextBox)(e.Item.Cells[4].Controls[0]); dtmDuedate = tb.Text; tb = (TextBox)(e.Item.Cells[5].Controls[0]); strContact = tb.Text; tb = (TextBox)(e.Item.Cells[6].Controls[0]); strLocation = tb.Text; da.Update(ds, "tblTasks"); DataGrid1.EditItemIndex = -1; DataGrid1.DataBind(); }



Reply With Quote