Click here to Skip to main content
15,886,724 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have GridView which include Two columns. I want to add GridView data into another Table means one tables multiple columns and rows data into another tables's single row. I am trying this query which is not valid for me becuase i have these variable also
objProduct.Tax1Name
objProduct.Tax1Rate
objProduct.Tax2Name
objProduct.Tax2Rate
objProduct.Tax3Name
objProduct.Tax3Rate
objProduct.Tax4Name
objProduct.Tax4Rate
objProduct.Tax5Name
objProduct.Tax5Rate

and all this need to include in this foreach loop which is not possible for me.
C#
foreach (DataGridViewRow daRw in gvTaxingScheme.Rows)
{
   objProduct.Tax1Name= daRw.Cells["ColumnTaxName"].Value.ToString();
   objProduct.Tax1Rate = Convert.ToDecimal(daRw.Cells["ColumnTaxRate"].Value);
} 

how to add one's tables multiple columns rows into another table??
Posted
Updated 11-Jun-14 5:39am
v3
Comments
Thava Rajan 11-Jun-14 8:35am    
can you clear the question please? i am not able to understand what you want tod, so please rephrase your question

1 solution

My suggestion is that you populate your Grid with a global list that can be accessed any time for any reason you want.

This way you will have the power of a list available everytime you go to the server, at a low cost of memory.

basically, just populate your gridview datasource like this:

C#
List< MyCustomObject> list = new List< MyCustomObject>();

public void PopulateGrid()
{
list.Clear();

list.Add(new MyCustomObject() { ... });
...


grid.DataSource = list;
grid.DataBind();

}


.
.
.
C#
public class MyCustomObject
{
    public int ID { get;set; }
    [...]
}
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900