Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9267073
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T14:27:53+00:00 2026-06-18T14:27:53+00:00

I have a grid which is being bound in code behind in which i

  • 0

I have a grid which is being bound in code behind in which i want to display template field also.

I am generating 3 columns in DataTable for grid view and the template field is TextBox control.

My code for binding data is..

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;


public partial class gr4 : System.Web.UI.Page
{
    SqlConnection cn;
    SqlCommand cmd;
    SqlDataAdapter da;
    DataSet ds;

protected void Page_Load(object sender, EventArgs e)
{
    cn = new SqlConnection("Data Source=AMIR-PC\\MOHEMMAD;Initial Catalog=CRM_InvestPlus;Integrated Security=True");
    string query = "Select Capacity from Dealer_License_Capacity where ID='D00001' and Software_ID='001' and Version_ID='1'";
    cn.Open();
    cmd = new SqlCommand(query,cn);
    da = new SqlDataAdapter(cmd);
    ds = new DataSet();
    da.Fill(ds);
    cn.Close();

    DataTable dt = new DataTable();
    dt.Columns.Add("Name", typeof(string));
    dt.Columns.Add("Software_Name", typeof(string));
    dt.Columns.Add("Version_Name", typeof(string));

    int count = Convert.ToInt32(ds.Tables[0].Rows[0][0].ToString());

    for (int i = 0; i < count; i++)
    {
        DataRow dr = dt.NewRow();
        dr["Name"] = "aaa";
        dr["Software_Name"] = "bbb";
        dr["Version_Name"] = "ccc";

        dt.Rows.Add(dr);
    }

    GridView1.DataSource = dt;
    GridView1.DataBind();
   }
}

My source code for grid view is:

    <asp:GridView ID="GridView1" runat="server">
    <Columns>

        <asp:TemplateField>
            <ItemTemplate>
                <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
            </ItemTemplate>
        </asp:TemplateField>

    </Columns>
    </asp:GridView>

</div>
</form>

The grid display template field as first column but I want to display the template field as last column in output. Can I add more template fields in this grid..??

Please help..

Thanks in advance

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T14:27:54+00:00Added an answer on June 18, 2026 at 2:27 pm

    You can use bound fields like below

      <asp:GridView ID="GridView1" runat="server"  AutoGenerateColumns="false" > /*changed to false*/
         <Columns>
           <asp:BoundField HeaderText="Name" 
               DataField="Name"/>
           <asp:BoundField HeaderText="SoftwareName" 
               DataField="Software_Name"/>
           <asp:BoundField HeaderText="VersionName" 
               DataField="Version_Name"/>
    
           <asp:TemplateField>
               <ItemTemplate>
                   <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
               </ItemTemplate>
           </asp:TemplateField>
        </Columns>
    </asp:GridView>
    

    You can change the order as you like.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a grid view which contains a button in a template field. I
I have a Grid View which works, the data bound columns extract the proper
i have this line of code in my view using the Telerik Grid: columns.Bound(o
I have a grid which has 4 bands and the columns in band[3] are
I have a Grid which contains an Image in one of its columns. The
I have a Telerik Grid which has a footer that needs to display column
I have a grid bound to a BindingSource which is bound to DataContext table,
I have a Kendo UI grid with a custom column as such: columns.Template(@<text></text>) .Width(50)
So basically I have data being pulled from a database for which I want
I have a table which I'm displaying in a grid. I'm being asked to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.