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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T18:23:26+00:00 2026-05-20T18:23:26+00:00

this might be a stupid question, but I’m using asp.net list control that creates

  • 0

this might be a stupid question,

but I’m using asp.net list control that creates a table with <div> elements that have a picture thumbnail, and when the user clicks on the div and it calls Ajax method and populates a shared dialog with correct information, and then shows it to the user. In order to do this the div needs to know the item id associated with it, so it can do the db lookup.

Right now I’m doing stuff like <div id="item<% Eval(Id) %>Widget" onmouseover="GetInfo(<% Eval(Id) %>" and then the GetInfo(id) method does so work to look up information and show and hide the appropriate elements to the user, etc. I recently read about the jquery .data() method and that sounds like a cleaner solution, because ideally in my <itemtemplate> I would associate the id with div tag (as its being written), that way the id doesn’t show up in the source (i.e GetInfo(5)) ( this is not a big deal, as i don’t care too much that user can see this id), but my secondary and biggest motivation is to be able to bind a click method by class name rather then id, so ideally something like $(".itemWidget).hover(func (show/hide stuff));

So my questions boils down to, how do you dynamically store data to a div item in a list view loop.

so something like

<listControl>
  <ItemTemplate>
    < div>
       stuff
       thisdiv.data(<% Eval(id) %>); // <-unsure about this part
    </div>
  </ItemTemplate>
</listControl>

Thanks for any help you can provide!

  • 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-20T18:23:26+00:00Added an answer on May 20, 2026 at 6:23 pm

    I think what you are looking for is the HTML5 custom data attributes. You can include them into the markup like this…

    <ItemTemplate>
      <div class="whatever" data-id="<%= Eval(id) %>">
       stuff
      </div>
    </ItemTemplate>
    

    And then with jQuery (1.4.3 and above) you can easily get at it using data like this…

    $(".whatever").hover(
      function() {
        //show
        var id = $(this).data("id");
        alert(id);
        GetInfo(id);
      },
      function() {
        //hide
      }
    );
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This might be a stupid question but if there's a better or proper way
This might be a stupid question but I just wanted to make sure... If
This might be a stupid question, but I can't for the life of me
This might sound like a stupid question, but google didn't help me. Is there
This might seem like a stupid question I admit. But I'm in a small
This might be a stupid question but I'm new at all this. I want
This might be a stupid question but I'll ask anyway, I was reading OOP
This might be a stupid question but how to update System.Web.Mvc dll which is
So this might be a stupid question but... I want to package a specific
This might sound like a stupid question but ... will WPF stop running in

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.