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 using Nullable Types in C#?

1 Answers  


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

8 Answers   Black Pepper, Infosys, Mind Tree,


Hello Sir, Thanks for the Solution but, can you pls. Explain the coding for the Static Function & static variable from the below coding....waiting for Ans. class fact { public static void Main() { fact f=new fact(); int x=1; //Declaration of x as 1 int k=Convert.ToInt32(Console.ReadLine()); for(int i=1;i<=k;i++) { x= x *i; } System.Console.WriteLine(x); } }

0 Answers  


Write a program to convert postfix expression to infix expression.

0 Answers   Mind Tree,


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

1 Answers   Satyam,






how do i copy textbox contents of 1 form to another form

4 Answers   Wipro,


Give the code for Handling Mouse Events?

0 Answers  


working with arrays

1 Answers  


Create a class called Accounts which has data members like ACCOUNT no, Customer name, Account type, Transaction type (d/w), amount, balance D->Deposit W->Withdrawal If transaction type is deposit call the credit(int amount) and update balance in this method. If transaction type is withdraw call debit(int amt) and update balance. Pass the other information like Account no,name,Account Type through constructor. Call the show data method to display the values.

1 Answers   Cognizant,


Coding for Manipulate XML File Data Using C#?

1 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  


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)