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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T06:15:26+00:00 2026-06-14T06:15:26+00:00

I have an listview and some codebehind with OnItemCommand commands doing some operation on

  • 0

I have an listview and some codebehind with “OnItemCommand” commands doing some operation on my web-application. I want to add a entry out of the ListView to an MySql Database by clicking on an icon in that ListView.

The Listview is not that small and sometimes you have to scroll down to find the right entry. If I click one of those button the page makes a reload an scrolls to the top of the page. But I want the page to stay on the position. I don´t want to scroll down after every click to find where I was before.

Anyone some ideas how to do this?

Here is my codebehind of the ListView_OnItemCommand:

protected void addTextModuleList_OnItemCommand(object sender, ListViewCommandEventArgs e)
    {
        // read the ticket ID from e
        ListViewDataItem dataItem = (ListViewDataItem)e.Item;

        if (String.Equals(e.CommandName, "insertTextModule"))
        {
            //connect to database
            MySqlConnection con = new MySqlConnection();
            con.ConnectionString = Helper.CONNECTION_STRING;
            MySqlCommand cmd = null;

            // insert new entrys for customer            
            cmd = new MySqlCommand();
            con.Open();
            cmd.Parameters.AddWithValue("@customer", Session["currentCustomerId"]);
            int id = Convert.ToInt16(addTextModuleList.DataKeys[dataItem.DisplayIndex].Value.ToString());
            cmd.Parameters.AddWithValue("@textModule", id);
            cmd.Parameters.AddWithValue("@confirmationId", Session["currentConfirmationId"].ToString());
            cmd.CommandText = "INSERT INTO linktextmodule (customer, textModule, confirmationID) " + "VALUES(@customer, @textModule, @confirmationId)";
            cmd.Connection = con;
            cmd.ExecuteNonQuery();
            con.Close();

            //change the cssClass of the linkButton
            LinkButton addTextModuleButton = e.Item.FindControl("addTextModuleButton") as LinkButton;
            addTextModuleButton.CssClass = "insertTextModuleButton";
        }
    }
  • 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-14T06:15:28+00:00Added an answer on June 14, 2026 at 6:15 am

    You can use this two methods to maintain the page position on postback

    In the page declaration

    <%@ Page MaintainScrollPositionOnPostback="true" %>
    

    Or in the web.config file.

    <pages maintainScrollPositionOnPostBack="true" />
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a Listview with some data.I want to get the number of click
I have a ListView of items, and I want to run some code every
I have a listView with some data coming from a server.I want to do
I have some ListView and I want that they all have the same View
I have a ListView with some elements and I want to change the background
I have listview having customized some textview and one imageview. When I long click
I have a ListView with some items. I have toggleButton in each row of
I have a ListView with multiple choice entries where some are checked from the
I have a listview and each item has a title, some info, and a
Background: I have a ListView / GridView with several columns. In some situations, only

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.