ASP.NET Gridview(TemplateField)

Joined
Mar 19, 2008
Messages
2
Reaction score
0
Hi All,
I tried to create a gridview and add a templatefield.
But i had a problem with itemtemplate.
Here is the which i have written.

public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
SqlConnection cn = new SqlConnection();
cn.ConnectionString = "Server=SQL;Integrated Security = true;Database=test;Persist Security Info=true";
cn.Open();
SqlDataAdapter da = new SqlDataAdapter("select * from Customer", cn);
DataSet ds = new DataSet();
da.Fill(ds);
GridView gv1 = new GridView();
gv1.DataSource = ds;
gv1.AutoGenerateColumns = false;
TemplateField tf = new TemplateField();
tf.HeaderText = "Customer Id & Name";
tf.ItemTemplate.InstantiateIn = ???!! <== here is place where i don't know what to do.
(I want to join to two columns I.e., FName and Lname as Name in the Gridview by adding to labels.)
gv.Columns.Add(tf);
gv1.DataBind();
}

I got the similar code using asp tags.

If any one know how to do this or know any links where i can find some resources for this , help me
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,770
Messages
2,569,586
Members
45,097
Latest member
RayE496148

Latest Threads

Top