How to pass multiple rows from one gridview to another
gridview after clicking the checkbox.



How to pass multiple rows from one gridview to another gridview after clicking the checkbox...

Answer / srividhya

int i;
DataTable ObjDT = new DataTable();

DataColumn objcol1 = new DataColumn();
objcol1.DataType =
System.Type.GetType("System.Int16");
objcol1.ColumnName = "Category_id";
ObjDT.Columns.Add(objcol1);

DataColumn objcol2 = new DataColumn();
objcol2.DataType =
System.Type.GetType("System.String");
objcol2.ColumnName = "Category_Name";
ObjDT.Columns.Add(objcol2);

DataColumn objcol3 = new DataColumn();
objcol3.DataType =
System.Type.GetType("System.String");
objcol3.ColumnName = "Description";
ObjDT.Columns.Add(objcol3);

DataColumn objcol4 = new DataColumn();
objcol4.DataType =
System.Type.GetType("System.String");
objcol4.ColumnName = "Messages";
ObjDT.Columns.Add(objcol4);

for (i = 0; i < radGridView1.Rows.Count; i++)
{
if
(radGridView1.Rows[i].Cells[0].Value.ToString().ToUpper() ==
"TRUE")
{
DataRow ObjRow = ObjDT.NewRow();

ObjRow["Category_Id"] =
radGridView1.Rows[i].Cells[1].Value;
ObjRow["Category_Name"] =
radGridView1.Rows[i].Cells[2].Value;
ObjRow["Description"] =
radGridView1.Rows[i].Cells[3].Value;
ObjRow["Messages"] =
radGridView1.Rows[i].Cells[4].Value;
ObjDT.Rows.Add(ObjRow);

}
}
radGridView2.DataSource = ObjDT;

foreach (GridViewDataColumn column in
radGridView2.Columns)
{
column.BestFit();
}

Is This Answer Correct ?    4 Yes 1 No

Post New Answer

More C Sharp Code Interview Questions

Coding for Manipulate XML File Data Using C#?

1 Answers  


Write a program to count 3Letter, 4Letter and 5Letter words from a file and print the number of 3Letter, 4Letter and 5Letter words. Delimiter is space, tab, hifen. Also we should not consider the line in the file after we encounter # in that line.

0 Answers   Mind Tree,


How to Link Different Data Sources Together?

0 Answers  


program for string reverse(eg:- i am boy -> boy am i)

8 Answers   Black Pepper, Infosys, Mind Tree,


How to export 2 datatables of a single dataset to 2 different worksheets of a single MSExcel file ?

0 Answers   Eastcom Systems,






working with arrays

1 Answers  


Can you declare an array of mixed Types?

1 Answers   HCL,


Give the code for Handling Mouse Events?

0 Answers  


. Write a program to print the following outputs using for loops $ $ $ $ $ $ $ $ $ $ $ $ $ $ $

3 Answers  


How to add a value from textBox over an existing certain column in SQL Server

0 Answers  


c# coding for a program that takes a 3 digit number n and finds out whether the number 2^n + 1 is prime, or if it is not prime find out its factors not using the Big-integer and Exponential Function's.

1 Answers   TCS,


Write a program to convert postfix expression to infix expression.

0 Answers   Mind Tree,


Categories
  • ASP.NET Code Interview Questions ASP.NET Code (46)
  • VB.NET Code Interview Questions VB.NET Code (9)
  • C Sharp Code Interview Questions C Sharp Code (51)
  • ADO.NET Code Interview Questions ADO.NET Code (8)