0

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

Edited by __avd: Added [code] tags. For easy readability, always wrap programming code within posts in [code] (code blocks).

3
Contributors
2
Replies
3
Views
7 Years
Discussion Span
Last Post by dnanetwork
0

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();
   }
}
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.