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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T05:54:38+00:00 2026-05-15T05:54:38+00:00

I have a problem i have some dynamic button.and i want to store integer

  • 0

I have a problem i have some dynamic button.and i want to store integer value in that.

and get that value on that click event of that button how can i achieve it

thanks in advance
shashank

DataView dv = new DataView(dtCat, "PK_CATEGORY_ID IN(" + categoryIds.ToString() + "0)", "PK_CATEGORY_ID", DataViewRowState.CurrentRows);

foreach (DataRowView rr in dv)
{
    //MessageBox.Show(rr[0].ToString() + "------------" + rr[1].ToString());

    Button b2 = new Button();

    //b2.Name = rr[0].ToString();
    b2.Name = "";
    b2.Height = 200;
    b2.Width = 200;
    b2.Margin = new Thickness(0, -100, 0, 0);
    b2.HorizontalAlignment = HorizontalAlignment.Left;
    b2.Content = rr[1].ToString();
    b2.Background = System.Windows.Media.Brushes.Pink;
    b2.Click += new RoutedEventHandler(b2_Click);
    btncanvas.Children.Add(b2);
    Canvas.SetLeft(b2, b2.Width * i);
    i = i + 1;
    MessageBox.Show(rr[0].ToString());
    b2.Tag = rr[0].ToString();

}


void b2_Click(object sender, RoutedEventArgs e)
{
    Button clicked = (Button)sender;

    categoryname = clicked.Name;
}
  • 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-15T05:54:38+00:00Added an answer on May 15, 2026 at 5:54 am

    The Tag property is probably what you want.

    You are already using it in your example, but just have:

    b2.Tag = integerValue;
    

    Then in your click handler use Convert.ToInt32(object) method to get the integer value back:

    int retrievedValue = Convert.ToInt32(clicked.Tag);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have some dynamic radio button, now my problem is how can i detect
Problem I have some pages that need dynamic data from website to generate output
I have some problem with MySQL Workbench in that I sometimes can't set foreign
i have some problem.. i have created a dynamic button in a table view.
I have this problem where I can't get my dynamic data web app to
I have some problem to get the utf-8 string from PHP using jQuery $.load()
I have some problem. Dialog.dismiss() does not work. I want to input ip, username,
Boxes are some objects(button, label, textarea). Green's size is dynamic. Especially I have a
I have a problem that i have a dynamic field in schema.xml as <dynamicField
I have some problem with the cursor when using JOprionPane. I set a cursor

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.