Click here to Skip to main content
15,898,134 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I want to set colums, TemplateFied,HeaderTemplate,ItemTemplate with (LinkButton-Text,CommandName,Onclick etc)
Here I am showing my code t_name table name it is varable,I want to set
various table contains various field,Then I want generate Dynamically Gridview with the above properties.
string str = System.Configuration.ConfigurationManager.ConnectionStrings["sql"].ConnectionString;
        SqlConnection con = new SqlConnection(str);
        SqlCommand cmd;
        SqlDataAdapter ad = new SqlDataAdapter();
        con.Open();
        cmd = new SqlCommand("select * from t_name", con)
        ad.SelectCommand = cmd;
        DataSet ds = new DataSet();
        ad.Fill(ds, t_name);
            GridView1.DataSource = ds;
            GridView1.DataBind();
Posted
Updated 28-Sep-10 21:50pm
v2

1 solution

THIS[^] will show you the Use of Template field in gridview.

Or you could have some further understanding with THIS[^]

Please vote and Accept Answer if it Helped.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900