gridview to database
-
Hi i have a gridView with 4columns(Btncolumn, StartAmount, EndAmount, AccountShare which is bound to a datatable. I want to store the last 3 columns value in a database in tblSlab taking either from gridView or datatable..... how to do this....
Sangram (A battle with self) Life is simple, we are the ones makes the living difficult
-
Hi i have a gridView with 4columns(Btncolumn, StartAmount, EndAmount, AccountShare which is bound to a datatable. I want to store the last 3 columns value in a database in tblSlab taking either from gridView or datatable..... how to do this....
Sangram (A battle with self) Life is simple, we are the ones makes the living difficult
sangramkp wrote:
I want to store the last 3 columns value in a database in tblSlab taking either from gridView or datatable.....
for(int i=Datatable.Row.Count-3;i<Datatable.Row.Count;i++)
{
//Get values from DT
//Form query and execute
}
-
Hi i have a gridView with 4columns(Btncolumn, StartAmount, EndAmount, AccountShare which is bound to a datatable. I want to store the last 3 columns value in a database in tblSlab taking either from gridView or datatable..... how to do this....
Sangram (A battle with self) Life is simple, we are the ones makes the living difficult
Hi there sangramkp, From what i understand in your requirement is that you want to take the values from an already populated GridView control and insert the last three columns into a table called tblSlab. You will need to iterate through the GridView's Rows property and extract the cells by index since you know which ones you need, consider the following code:
foreach (GridViewRow row in GridView.Rows) { // You indicated you wanted the last three cells... // Note that the cells collection is zero based... sqlScript = "Insert Into tblSlab Values(" + row.Cells[1].Text + ", " + row.Cells[2].Text + ", " + row.Cells[3].Text + ", "; // Now execute your code to insert the record into your table... }
And thats it... Have fun! :) -- modified at 6:18 Friday 14th September, 2007
Fernando Mendes Senior .NET Developer, Architect