Interview answers verified by specialists.

Find interview questions and answers on this website:

See right interview answers on 30 common job interview questions

How will you fill the GridView by using DataTable object at runtime?

using System;
using System.Data;
public partial class Default : System.Web.UI.Page
protected void Page_Load(object sender, EventArgs e)
DataTable dt = new DataTable("Employee"); // Create the table object
DataColumn dc = new DataColumn();
DataRow dr;
dc.ColumnName = "ID"; //Heading of the coloumn 
dc.DataType = Type.GetType("System.Int32"); //Set the type of ID as Integer 
dc = new DataColumn(); 
dc.ColumnName = "ItemName"; 
dc.DataType = Type.GetType("System.String"); //Set the type of ItemName as String 
for (int i = 0; i <= 4; i++) //This code will create 5 new rows 
dr = dt.NewRow();
dr["id"] = i; 
dr["ItemName"] = "Item " + i;
GridView1.DataSource = dt; 

Do you know that?

Your client is not always right and it is okay to respectfully disagree. Next