473,385 Members | 1,907 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

copying the one gridview cell value to another gridview

Hi
i need to copy the one gridview cellvalue to another gridview
eg:
gridview1:
a b c
1 s 2
2 v 3
3 d 4

The Second Gridview Value Should Be
a g h
1
1
2
2
2
3
3
3
but i am getting the last value 3 in each row.
My Coding
Expand|Select|Wrap|Line Numbers
  1. ArrayList da1 = new ArrayList();
  2.             ArrayList da2 = new ArrayList();
  3.             int a1 = 0;
  4.             int  a2 = 0;
  5.  
  6.            int id=0;
  7.            foreach (GridViewRow row2 in grv2.Rows)
  8.            {
  9.                foreach (GridViewRow row1 in grv1.Rows)
  10.                {
  11.  
  12.  
  13.                    a1 = int.Parse(row1.Cells[3].Text);
  14.                    da1.Add(a1);
  15.                    da2.Add(a2);
  16.  
  17.  
  18.                    foreach (int ir in da1)
  19.                    {
  20.                        if (id < ir)
  21.                        {
  22.  
  23.                            row2.Cells[1].Text = row1.Cells[1].Text;
  24.  
  25.                        }
  26.  
  27.                    }
  28.                }
  29.  
  30.         }
  31.  
can any say me what is wrong in it
Feb 19 '11 #1
3 4159
Frinavale
9,735 Expert Mod 8TB
Why don't you try binding both GridViews to the same datasource...or even a copy of the DataSource?
Feb 22 '11 #2
i need to copy only the first column value of first gridview in second gridview Like

gridview1
a b c
1 s 4
2 sw 3

in the second gridview the values should be like
a h t
1
1
1
1
2
2
2
Feb 23 '11 #3
humm... seems to me that this could be done with a query and then past that into the gridview.

Expand|Select|Wrap|Line Numbers
  1. List<column data type> bla = new List<column data type>();
  2.  
  3. for (int i = 0, i < System.Data.SqlClient.SqlCommand("Select Count(column name) From table"); i++)
  4. {
  5.   bla.Items.Add(System.Data.SqlClient.SqlCommand("Select column name From table Where primaryKeyID = @prim")
  6. System.Data.SqlClient.SqlCommand.Parameters.Add("prim", System.Data.SqlDbType.column data type).Value = i;
  7. }
  8.  
  9. New Gridview = bla;

Hope this helps.
Nov 24 '11 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Jon S via DotNetMonster.com | last post by:
HI all, I'm returning a dataset to a gridview control. When the gridview asp.net control is populated from the returning dataset some of the cells remain empty. This is expected as some data...
3
by: Chris | last post by:
Hi, In ASP.NET 2005, I am using a gridview control. I have some Buttons in gridview for opening different forms. I use ROWCOMMAND event for retrieving the name of the button pressed. Can I...
3
by: Bill Gower | last post by:
I have an cell which contains a field member which is filled with String.Empty. When I retrieve the value in the cell with Cells.Text.ToString() and try to compare it to String.Empty, I can't...
14
by: Mike | last post by:
I have a gridview that has a button in the last cell of each row. I want to get the text from cell 1 for that row the button was clicked on. So if my gridview looks like this: N-12 BMW ...
1
by: Vyas111111 | last post by:
Hello All, How can i get the value of a gridview cell outside any GridView event
4
by: foolmelon | last post by:
Before AJAX, we were able to focus a cell in a gridview during a fullpage postback. After putting the gridview inside an UpdatePanel, we cannot focus a cell in this gridview anymore. Does anybody...
3
by: bharathi228 | last post by:
hi, iam doing one asp.net application in gridview i have 3 columns. the first two column values are coming from database. the third column is template field.here i have one...
2
by: renuami | last post by:
We have a GridView2 in GridView1 EditTemplate. And we have a button (commandname="Update") on GridView2. When Button1 is clicked GridView1 goes into edit mode and displays GridView2. Now when...
2
by: yahshuatwo | last post by:
How can you display an icon the gridview cell column which is dependent on the text value of an adjacent column. Also, I setup the asp template,item and image controls, do i need to set the imgURL...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.