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

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

0 Answers  


how to change password in .net with c # with ado.net and also SQL server 2008 change password

1 Answers  


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

8 Answers   Black Pepper, Infosys, Mind Tree,


how to get the table names via c sharp and column names also?

2 Answers   Sify,


how does the below eqation proceed to be solved: x*=y+z options: x=x*y+z or x=x*(y+z)

1 Answers  






Write a program to convert postfix expression to infix expression.

0 Answers   Mind Tree,


Give the code for Handling Mouse Events?

0 Answers  


Code for Reading and writing from a file?

0 Answers   IBM, Xoriant,


Write a function which accepts list of nouns as input parameter and return the same list in the plural form. Conditions: i) if last letter is r then append s ii) if word ends with y then replace it by ies iii) call this function in main() and produce the required output. for eg:- if chair is input it should give chairs as output.

0 Answers   Mind Tree,


Write a program to input an integer and - display the reverse - display the sum of each digit - should include logic that considers the input number as any number of digits long

2 Answers   Mind Tree,


Can you declare an array of mixed Types?

1 Answers   HCL,


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  


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)