Data is coming into dataset and the remaining work is only to display in proper order.
SqlConnection sqlCon = new SqlConnection(strCon);
sqlCon.Open();
SqlCommand cmd = new SqlCommand("SearchCustomerbyMobile", sqlCon);
cmd.Parameters.Add("@asMobile", SqlDbType.NVarChar).Value = tbxMobileNo.Text;
cmd.CommandType = CommandType.StoredProcedure;
SqlDataAdapter adapter = new SqlDataAdapter(cmd);
DataSet ds = new DataSet();
adapter.Fill(ds);
if (ds.Tables[0].Rows.Count > 0)
{
this.dgvActiveCustomer.CellValueNeeded += new GridViewCellValueEventHandler(dgvActiveCustomer_CellValueNeeded);
this.dgvActiveCustomer.CellValuePushed += new GridViewCellValueEventHandler(dgvActiveCustomer_CellValuePushed);
dgvActiveCustomer.VirtualMode = true;
dgvActiveCustomer.ColumnCount = ds.Tables[0].Columns.Count;
this.dgvActiveCustomer.RowCount = ds.Tables[0].Rows.Count;
moBileDs = ds;
}
And in CellValueNeed event I worte like this:-
private void dgvActiveCustomer_CellValueNeeded(object sender, Telerik.WinControls.UI.GridViewCellValueEventArgs e)
{
e.Value = moBileDs.Tables[0];
}
Result ="Table" in entire rows and columns in the gridview.