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

  • Home
  • SEARCH
  • 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 6098005
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T13:06:28+00:00 2026-05-23T13:06:28+00:00

I have a GridView that pulls data out of the database and populates its

  • 0

I have a GridView that pulls data out of the database and populates its fields automaticaly.

<asp:GridView ID="gvData" runat="server" CellPadding="4" 
        ForeColor="#333333" GridLines="None" AllowPaging="True" AutoGenerateDeleteButton="True" 
        AutoGenerateEditButton="True" DataSourceID="DS" PageSize="1"  CssClass="q">
        <RowStyle BackColor="#F7F6F3" ForeColor="#333333" Height="20"  CssClass="q"/>
        <FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
        <PagerStyle BackColor="#284775" ForeColor="White" />
        <SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" />
        <HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
        <EditRowStyle BackColor="#999999" Height="15px" />
        <AlternatingRowStyle BackColor="White" ForeColor="#284775" />
    </asp:GridView>
    <asp:SqlDataSource ID="DS" runat="server"></asp:SqlDataSource>

Some of the fields are too long. Is there any way to cut the length of the text and insert a button that pops-up a new window with text?
The gridview aslo generates Edit and Delete buttons. Pressing an Edit button gives me little texboxes. How can I work around them to make the same button with a popup window for editing?

Another way that I thought of was creating a textarea with scrollbar. I know how to add a field with a scrollbar manually but it is created as a label, so when I press Edit, this field is not editable. And again, it is manual, but my gridview is auto populated. How can I populate large fields with textareas with scrollbars automatically?

Any help will be greatly appreciated! Thank you!


Okay, so I found a solution for shortening text:

protected void gvData_RowDataBound(object sender, GridViewRowEventArgs e)
{
    if (e.Row.RowType == DataControlRowType.DataRow)
    {
        for (int i = 0; i < e.Row.Cells.Count; i++)
        {
            ViewState["OrigData"] = e.Row.Cells[i].Text;
            if (e.Row.Cells[i].Text.Length >= 30)
            {
                e.Row.Cells[i].Text = e.Row.Cells[i].Text.Substring(0, 30) + "...";
                e.Row.Cells[i].ToolTip = ViewState["OrigData"].ToString();
            }
        }

    }

} 

Then add OnRowDataBound=”gvData_RowDataBound”:

<asp:GridView ID="gvData" runat="server" CellPadding="4" ForeColor="#333333"
 GridLines="None" AllowPaging="True" AutoGenerateDeleteButton="True"
 AutoGenerateEditButton="True" DataSourceID="DS" PageSize="1"  
 OnRowDataBound="gvData_RowDataBound">   

This cuts the length to 30 characters and displays the full text in the ToolTip.

  • 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-23T13:06:28+00:00Added an answer on May 23, 2026 at 1:06 pm

    Answer to the second part:

        protected void gvData_PreRender(object sender, EventArgs e)
    {
        if (this.gvData.EditIndex != -1)
        {
            TextBox tb = new TextBox();
    
            for (int i = 0; i < gvData.Rows[gvData.EditIndex].Cells.Count; i++)
                try
                {
                    tb = (TextBox)
                        gvData.Rows[gvData.EditIndex].Cells[i].Controls[0];
    
                    if (tb.Text.Length >= 30)
                    {
                        tb.TextMode = TextBoxMode.MultiLine;
                    }
                }
                catch { }
             }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a gridview that fill it with some data. <asp:GridView ID=GridView1 runat=server ClientIDMode=Static>
I have a GridView that pulls the data from an Oracle DataBase dynamically. <asp:GridView
hello I have a code that pulls the data to the gridview using a
I have a gridview that shows an image as part of one of its
I have a gridview that displays items details, I added two template fields one
I have GridView that allows select. It takes data from EntityDataSource . How do
I have an ASPX page that creates a Gridview. My JQuery function pulls values
I have a GridView on an ASP.NET page with a TemplateField column that has
So, I have a GridView , CustomerGridView, and a SqlDataSource , SqlDataSource1, that pulls
I have a gridview that needs to be exported to Excel. I have managed

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.