ASP.NET Gridview(TemplateField)

Discussion in '.NET' started by manojbabu, Mar 19, 2008.

  1. manojbabu

    manojbabu

    Joined:
    Mar 19, 2008
    Messages:
    2
    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
    manojbabu, Mar 19, 2008
    #1
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. lupina
    Replies:
    3
    Views:
    27,192
    =?Utf-8?B?RWx0b24gVw==?=
    Mar 1, 2006
  2. markm75c@msn.com
    Replies:
    2
    Views:
    15,819
    markm75c@msn.com
    Jun 14, 2006
  3. sloan
    Replies:
    2
    Views:
    4,880
    aryan_subhash
    Oct 17, 2007
  4. mesut
    Replies:
    0
    Views:
    556
    mesut
    Jun 29, 2007
  5. Arne

    asp:templatefield in a Gridview

    Arne, Aug 14, 2007, in forum: ASP .Net Web Controls
    Replies:
    1
    Views:
    151
    Manish Bafna
    Aug 18, 2007
Loading...

Share This Page