DataGrid to DataBase
-
Hi, I have a DataGrid with the following columns: Remove, ItemName, ItemID, Size, Date, Amount. When the user clicks "Save" I need to cycle through the grid and if any of the Remove Checkboxes are checked, that row needs to get removed, but if the row isnt checked it gets saved to the database using a stored procedure with inputs (Project_ID, ItemID, Size, User). I know how to go through the DataGrid to check to see if the checkbox is checked and then to remove it, but I'm not sure how to take the non-checked rows and add them to the database. Can someone please help me with this code?
protected void btnSave_onClick(object sender, EventArgs e)
{
foreach (GridViewRow row in Control.GridViewRows)
{
CheckBox cboxremove = (CheckBox)row.FindControl("cbxRemove");
if (cboxremove.Checked)
{
RemoveCheckedTitles();
}
else
{
???????????????
}
}Please Help! Thanks
-
Hi, I have a DataGrid with the following columns: Remove, ItemName, ItemID, Size, Date, Amount. When the user clicks "Save" I need to cycle through the grid and if any of the Remove Checkboxes are checked, that row needs to get removed, but if the row isnt checked it gets saved to the database using a stored procedure with inputs (Project_ID, ItemID, Size, User). I know how to go through the DataGrid to check to see if the checkbox is checked and then to remove it, but I'm not sure how to take the non-checked rows and add them to the database. Can someone please help me with this code?
protected void btnSave_onClick(object sender, EventArgs e)
{
foreach (GridViewRow row in Control.GridViewRows)
{
CheckBox cboxremove = (CheckBox)row.FindControl("cbxRemove");
if (cboxremove.Checked)
{
RemoveCheckedTitles();
}
else
{
???????????????
}
}Please Help! Thanks
else
{
// call your stored procedure here for non checked item
}Navaneeth How to use google | Ask smart questions
-
else
{
// call your stored procedure here for non checked item
}Navaneeth How to use google | Ask smart questions
Thank you for your reply, however, I am not sure how to read in the data from the columns (columns: Remove, ItemName, ItemID, Size, Date, Amount) into my stored procedure that takes the following inputs (Project Id, ItemID, Size, User) where ProjectID and User are from the session but ItemID and Size are from the DataGrid.
-
Thank you for your reply, however, I am not sure how to read in the data from the columns (columns: Remove, ItemName, ItemID, Size, Date, Amount) into my stored procedure that takes the following inputs (Project Id, ItemID, Size, User) where ProjectID and User are from the session but ItemID and Size are from the DataGrid.
I think you can implement template field for those columns ,from where you want the data to be retrieved just like you are using the checkboxes and getting it by using row.findcontrol ,same try for this template field also.