Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP.NET Gridview(TemplateField)

Reply
Thread Tools

ASP.NET Gridview(TemplateField)

 
 
manojbabu manojbabu is offline
Junior Member
Join Date: Mar 2008
Posts: 2
 
      03-19-2008
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
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off




Advertisments