I have a problem filling a datagridview and it is that when filling it some data disappears in some cells, and I think it is because they are established with a predetermined format by the same datagrid when filled, I would like to know how to make all the data bring as a string or select a format by columns.
I add Codigo (I collect the data that there is in an excel and I add them in a datagrid)
//Aqui pregunto por la direccion donde esta el excel
DialogResult ListaUbiExcel = buscarlist.ShowDialog();
//Con esto valido la direccion y continuo con la sentencia
//dtgrilla es el nombre del DataGridView
if (ListaUbiExcel == DialogResult.OK)
{
buscarlist.Title = "Selecciona el archivo excel (xls, xlsx)";
buscarlist.Filter = "*.xls|*.xlsx|All files (*.*)|*.*";
dtgrilla.Enabled = false;
string Direccion = buscarlist.FileName;
String connString = "Provider=Microsoft.Jet.OLeDb.4.0;Data Source= " + Direccion + ";Extended Properties= \"Excel 8.0;HDR = YES\""; //Se crea el texto para la conexíón
OleDbConnection objConn = new OleDbConnection(connString);
objConn.Open();
DataTable dt = objConn.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, null);
OleDbCommand consultar = default(OleDbCommand);
consultar = new OleDbCommand("Select * from [Hoja1$]", objConn);
OleDbDataAdapter lista = new OleDbDataAdapter();
lista.SelectCommand = consultar;
DataSet ds = new DataSet();
lista.Fill(ds);
dtgrilla.DataSource = ds.Tables[0];
objConn.Close();