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 6751107
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T12:53:16+00:00 2026-05-26T12:53:16+00:00

I am trying to add a new column in a GridView but it doesn’t

  • 0

I am trying to add a new column in a GridView but it doesn’t show. Here is the code-behind where I setup the DataTable and set it as the DataSource of the GridView:

SqlDataAdapter da = new SqlDataAdapter();
DataTable dt = new DataTable();
SqlCommand cmd1;
DateTime d = DateTime.Now;
cmd1 = new SqlCommand("Proc_PopulateTitle", connection);
cmd1.CommandType = CommandType.StoredProcedure;
da.SelectCommand = cmd1;
da.Fill(dt);
dt.Columns.Add("Actions", Type.GetType("System.String"));
for (int i = 0; i < dt.Rows.Count; i++)
{                
    DateTime de = DateTime.Parse(dt.Rows[i][7].ToString());
    if (DateTime.Compare(de, d) < 0 || DateTime.Compare(de, d)==0)
    {
        dt.Rows[i]["Actions"] = "OPen";
    }
    else
    {
        dt.Rows[i]["Actions"] = "Expired";
    }
}
dt.GetChanges();
dt.AcceptChanges();


gvFaxView.DataSource = dt;

gvFaxView.DataBind();

Here is the GridView server-side markup code:

<asp:GridView ID="gvFaxView" runat="server" AllowPaging="True" AutoGenerateColumns="False"
    AutoGenerateSelectButton="True" CaptionAlign="Top" CssClass="text10" DataKeyNames="Fax_ID"
    PageSize="5" OnPageIndexChanging="gvFaxView_PageIndexChanging" OnSelectedIndexChanged="gvFaxView_SelectedIndexChanged">
    <FooterStyle BackColor="#348EC2" Font-Bold="True" ForeColor="White" />
    <Columns>
        <asp:TemplateField HeaderText="Fax Title">
            <ItemTemplate>
                <asp:Label ID="lbgvName" runat="server" Text='<%# Eval("Fax_Title") %>'></asp:Label>
            </ItemTemplate>
        </asp:TemplateField>
        <asp:TemplateField HeaderText="Fax Date">
            <ItemTemplate>
                <asp:Label ID="lbgvType" runat="server" Text='<%# Eval("Fax_Date") %>'></asp:Label>
            </ItemTemplate>
        </asp:TemplateField>
        <asp:TemplateField HeaderText="Fax Status">
            <ItemTemplate>
                <asp:Label ID="lbgvfName" runat="server" Text='<%# Eval("Fax_status") %>'></asp:Label>
            </ItemTemplate>
        </asp:TemplateField>
        <asp:TemplateField HeaderText="Fax Expire Date">
            <ItemTemplate>
                <asp:Label ID="lbgvNic" runat="server" Text='<%# Eval("Fax_Exp_Date") %>'></asp:Label>
            </ItemTemplate>
        </asp:TemplateField>
        <asp:TemplateField HeaderText="Open/Expire">
            <ItemTemplate>
                <asp:Label ID="lbgvopenexp" runat="server" Text="Open"></asp:Label>
            </ItemTemplate>
        </asp:TemplateField>
    </Columns>
    <RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
    <EditRowStyle BackColor="#999999" />
    <SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" />
    <PagerStyle BackColor="Maroon" ForeColor="White" HorizontalAlign="Center" />
    <HeaderStyle BackColor="Maroon" Font-Bold="True" ForeColor="White" />
    <AlternatingRowStyle BackColor="White" ForeColor="#284775" />
</asp:GridView>
  • 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-05-26T12:53:17+00:00Added an answer on May 26, 2026 at 12:53 pm

    I would set AutoGenerateColumns = False and remove your entire <Columns>...</Columns> tag. As you are pretty much generating your own DataTable, just set that as the source and bind. ASP should do the rest.

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

Sidebar

Related Questions

Here is my code Dim dt As DataTable = New DataTable(Intervenant) For Each column
I'm trying to add new output column using synchronous custom data flow component(below is
I'm trying to add a new node to an jQuery SimpleTree , but all
I'm trying to create a new contact and add it to the AddressBook but
I'm trying to set the HttpRequestHeader for a HttpWebRequest like so: new HttpWebRequest().Headers.Add(HttpRequestHeader.UserAgent, Mozilla/4.0);
I am trying to set the top gridview's column's width to the body's column
I am using MySQL 5.1. When i am trying to add new column, it
I'm trying to build a Editable GridView like control (Order column) with this code
I have an excel with 8 columns. I'm trying to add a new column
Hello I'm trying to add new column to the Excel worksheet by command ALTER

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.