Update Datagrid problem
-
When I try to update my databae using the update on the datagrid the original values, not the modified ones are passed. Any ideas? Thanks.(No, the function in its current state does not function) public void UpdateGrid(object sender, DataGridCommandEventArgs e) { UpdateVendor.Connection = Global.sqlConnection; UpdateVendor.Parameters[0].Value = dgVendors.DataKeys[(int)e.Item.ItemIndex]; TextBox Contact = (TextBox)e.Item.Cells[3].Controls[0]; TextBox Address = (TextBox)e.Item.Cells[4].Controls[0]; TextBox Phone = (TextBox)e.Item.Cells[5].Controls[0]; TextBox Fax = (TextBox)e.Item.Cells[6].Controls[0]; UpdateVendor.ExecuteNonQuery(); dgVendors.EditItemIndex = -1; dgVendors.DataBind(); } Steve Not all who wander are lost...
-
When I try to update my databae using the update on the datagrid the original values, not the modified ones are passed. Any ideas? Thanks.(No, the function in its current state does not function) public void UpdateGrid(object sender, DataGridCommandEventArgs e) { UpdateVendor.Connection = Global.sqlConnection; UpdateVendor.Parameters[0].Value = dgVendors.DataKeys[(int)e.Item.ItemIndex]; TextBox Contact = (TextBox)e.Item.Cells[3].Controls[0]; TextBox Address = (TextBox)e.Item.Cells[4].Controls[0]; TextBox Phone = (TextBox)e.Item.Cells[5].Controls[0]; TextBox Fax = (TextBox)e.Item.Cells[6].Controls[0]; UpdateVendor.ExecuteNonQuery(); dgVendors.EditItemIndex = -1; dgVendors.DataBind(); } Steve Not all who wander are lost...
I'm assuming TextBox Contact, etc. contain the updated values and UpdateVendor is your SqlCommand. Where are you assigning the contact, address, phone and fax to SqlCommand parameters?
-
I'm assuming TextBox Contact, etc. contain the updated values and UpdateVendor is your SqlCommand. Where are you assigning the contact, address, phone and fax to SqlCommand parameters?
here is the exact code. public void UpdateGrid(object sender, DataGridCommandEventArgs e) { UpdateVendor.Connection = Global.sqlConnection; UpdateVendor.Parameters[0].Value = dgVendors.DataKeys[(int).Item.ItemIndex]; TextBox Contact = (TextBox)e.Item.Cells[3].Controls[0]; TextBox Address = (TextBox)e.Item.Cells[4].Controls[0]; TextBox Phone = (TextBox)e.Item.Cells[5].Controls[0]; TextBox Fax = (TextBox)e.Item.Cells[6].Controls[0]; UpdateVendor.Parameters[1].Value = Contact.Text; UpdateVendor.Parameters[2].Value = Address.Text; UpdateVendor.Parameters[3].Value = Phone.Text; UpdateVendor.Parameters[4].Value = Fax.Text; UpdateVendor.ExecuteNonQuery(); dgVendors.EditItemIndex = -1; dgVendors.DataBind(); } Steve Not all who wander are lost...
-
here is the exact code. public void UpdateGrid(object sender, DataGridCommandEventArgs e) { UpdateVendor.Connection = Global.sqlConnection; UpdateVendor.Parameters[0].Value = dgVendors.DataKeys[(int).Item.ItemIndex]; TextBox Contact = (TextBox)e.Item.Cells[3].Controls[0]; TextBox Address = (TextBox)e.Item.Cells[4].Controls[0]; TextBox Phone = (TextBox)e.Item.Cells[5].Controls[0]; TextBox Fax = (TextBox)e.Item.Cells[6].Controls[0]; UpdateVendor.Parameters[1].Value = Contact.Text; UpdateVendor.Parameters[2].Value = Address.Text; UpdateVendor.Parameters[3].Value = Phone.Text; UpdateVendor.Parameters[4].Value = Fax.Text; UpdateVendor.ExecuteNonQuery(); dgVendors.EditItemIndex = -1; dgVendors.DataBind(); } Steve Not all who wander are lost...
Using DataGrid Look at the Checkboxes and TextBoxes section.