i use this method to fill data grid

public void fill()
     public void fill()
    {
        SqlConnection con = new SqlConnection(connStr);
        con.Open();
        SqlDataAdapter da = new SqlDataAdapter("Select * from Dept_Master", con);
        DataSet ds = new DataSet();
        da.Fill(table); 	
    }
    public void BindDG()
    {
        GridView1.DataSource = table;
        GridView1.DataBind();
    }
    public void Nrow()
    {
        table.Rows.InsertAt(table.NewRow(), 0); 
    }

hi...
i am new in asp.net i want to change column name at run time
to fill data grid i use Data Adapter plz tell me solution

Put your code in Page_load event,

void page_load() {
   if(!IsPostBack) {
        SqlConnection con = new SqlConnection(connStr);
        SqlDataAdapter da = new SqlDataAdapter("Select * from Dept_Master", con);
        DataTable table=new DataTable();
        da.Fill(table); 	
        GridView1.DataSource = table;
        GridView1.DataBind();
   }
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.