1
Reply

can i add new column in table through gridview?

roy himanshu

roy himanshu

Sep 9 2009 4:04 AM
4.7k

hi .all
can i add new column in data table through gridview  when form load?is it possible? plz tell how is it possible .my code is paste bellow.
private
void Form3_Load(object sender, EventArgs e)
{
cn =
new SqlConnection("data source=server2;database=costing1;user id=sa;password=sa");
da =
new SqlDataAdapter("select *from Itemmaster", cn);

DataTable dt = new DataTable();
dt.Columns.Add(
"column005", typeof(int));
ds =
new DataSet();
da.Fill(ds,
"Itemmaster");
cmd =
new SqlCommand();
cmd.Connection = cn;
cmd.CommandType =
CommandType.StoredProcedure;

dataGridView1 .DataSource =ds .Tables [
"Itemmaster"];
}

 

Answers (1)