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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T11:06:59+00:00 2026-06-17T11:06:59+00:00

I have written a method that retrieves data from the database and returns a

  • 0

I have written a method that retrieves data from the database and returns a datatable comprising of three columns.

This datatable I am binding to a gridview control after hiding the ID field.

        DataTable dt = _qbObj.getAllTags();
        dvTags.DataSource = dt;

        BoundField bfName = new BoundField();
        bfName.DataField = dt.Columns["Name"].ToString();
        bfName.HeaderText = "Name";

        BoundField bfId = new BoundField();
        bfId.DataField = dt.Columns["ID"].ToString();
        bfId.Visible = false;

        BoundField bfDesc = new BoundField();
        bfDesc.DataField = dt.Columns["Description"].ToString();
        bfDesc.HeaderText = "Description";            

        dvTags.Columns.Add(bfId);
        dvTags.Columns.Add(bfName);
        dvTags.Columns.Add(bfDesc);
        dvTags.DataBind();

To this gridview control, I want to add an edit button, which should pop-up a jquery modal dialog box where I can enter the updated details.

I realize that I can go with a , but the problem is that I need to pop that modal dialog box without refreshing the page, and the doesn’t exactly have great support for scripting.

So inside my gridview I inserted this, an Item Template.

        <asp:GridView ID="dvTags" runat="server" CssClass="labs-grid-view" 
            AutoGenerateColumns="False" >
            <Columns>   
                <asp:TemplateField>
                    <ItemTemplate>
                        <asp:Button ID="btnEdit" runat="server" Text="Edit" OnClick="dvTagEdit" CommandName="UpdateRecord"
                            CommandArgument='<%# Eval("ID") %>' />
                    </ItemTemplate>
                </asp:TemplateField>                                 
            </Columns>
        </asp:GridView>

Now after I am done editing the gridview doesn’t update automatically, and hence I have a dedicated refresh grid button which deletes the existing “dynamically inserted columns” using this code :-

        int noOfRows = dvTags.Columns.Count;
        if (noOfRows > 1)
        {
            dvTags.Columns.RemoveAt(noOfRows - 1);
            dvTags.Columns.RemoveAt(noOfRows - 2);
            dvTags.Columns.RemoveAt(noOfRows - 3);
            // THERE ARE A TOTAL OF **THREE** COLUMNS
        }  

But the problem is that after refreshing the page a couple of times, my button inside the ItemTemplate disappears and in the html is replaced with an ” “

Please help me find the error. I’m thinking there is a better and easier way to achieve this. If so I’m open to them.

Thanks for reading,

Abijeet.

  • 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-17T11:07:01+00:00Added an answer on June 17, 2026 at 11:07 am

    A few things to consider:

    First, can you post your code behind for your ItemCommand event, which is rendering the modal popup and which is performing the update? It could be that your refresh after edit is not processing properly.

    Second, instead of doing your databinding “inline” on your GridView, consider using the RowDataBound event within the Gridview. You can detect which row is being generated (header, data, footer) and you can properly create your edit button in there. Better yet, you can access your button from within this method and simply set the CommandArgument to your Id.

    Third, when using the asp button in your GridView, it will trigger the “ItemCommand” event when clicked, which will cause a postback.

    I’d recommend having a simple link in your template column, or something that you can use to trigger a jQuery modal, and you can setup a static naming convention for your items that will properly retrieve the data to put into your modal popup for editing. Then from there you should be able to process your update as normal.

    I hope something in here helps.

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

Sidebar

Related Questions

I have written a function that retrieves a html template, then binds data using
I have written a helper function that can retrieve content from a url. This
I have written php code to retrieve data from database to div in webpage.i
I have written an O/R database wrapper that generates some wrapper methods for stored
i have written a method in java like this public boolean ADD(String ID,String Name,String
I have written an extension method to help with collecting crash data during error
I have written this clone method for when the parent of the Employee class
I have a method written in VB.NET. It looks like this: Shared Sub SomeMethod(ByVal
I have written a login form, in this I have used, form and method
Hi all i have written a code to read the excel data from an

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.