473,398 Members | 2,812 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,398 software developers and data experts.

For loop in c#

i have abutton inside the datagrid.i am trying get the value of the button which button is clicked .trying to write a for loop but i don't have any idea please help me.if any one kanow about this.

my code is like this:

Expand|Select|Wrap|Line Numbers
  1. i have abutton inside the datagrid.i am trying get the value of the button which button is clicked .trying to write a for loop but i don't have any idea please help me.if any one kanow about this. 
  2.  
  3. my code is like this:
  4.  
  5. Code: ( text )
  6. private void Page_Load(object sender, System.EventArgs e)
  7. {
  8.  
  9. if(this.IsPostBack==false)
  10. {
  11. this.DisplayData(); 
  12. }
  13. else 
  14. this.DisplayChecked();
  15. string EomNomid;
  16. EomNomid = Request.QueryString["EomNomid"];
  17.  
  18. HtmlInputButton Submitbutton; 
  19.    DataGridItem item; 
  20. for (int counter = 0;counter <= this.gvEmployee.Items.Count-1; counter++) 
  21. item = gvEmployee.Items[counter]; 
  22. Submitbutton = ((HtmlInputButton)(item.FindControl"EmployeeNominationID"))); 
  23. if (Submitbutton.value=true)
  24.  
  25.  
  26.  
  27.  
Aug 14 '07 #1
8 2136
JosAH
11,448 Expert 8TB
This is not a C# forum; it's a C/C++ forum instead. Do you want me to move your
question to the .NET forum?

kind regards,

Jos

edit: oops, I think someone else did it already ;-)
Aug 14 '07 #2
ok move my question to the .net forum thanks
Aug 14 '07 #3
TRScheel
638 Expert 512MB
It looks like some code was cut off
Aug 14 '07 #4
Expand|Select|Wrap|Line Numbers
  1. private void Page_Load(object sender, System.EventArgs e)
  2.         {
  3.  
  4.             //             Put user code to initialize the page here
  5.             if(this.IsPostBack==false)
  6.             {
  7.                 this.DisplayData(); 
  8.             }
  9.                 else 
  10.                 this.DisplayChecked();
  11.             //            
  12.             string EomNomid;
  13.             EomNomid = Request.QueryString["EomNomid"];
  14.  
  15.             HtmlInputHidden objHidden; 
  16.             HtmlInputButton Submitbutton; 
  17.             DataGridItem item; 
  18.             for (int counter = 0;counter <= this.gvEmployee.Items.Count-1; counter++) 
  19.             { 
  20.             item = gvEmployee.Items[counter]; 
  21.                 Submitbutton = ((HtmlInputButton)(item.FindControl("EmployeeNominationID"))); 
  22.                 objHidden = ((HtmlInputHidden)(item.FindControl("employeeid"))); 
  23.  
  24. if (Submitbutton.CausesValidation==true)
  25.                 {
  26.  
  27. string employee=objHidden.Value;
  28.                     SqlConnection oConn = new SqlConnection(System.Configuration.ConfigurationSettings.AppSettings["oConn"]); 
  29.                     SqlCommand objCmd = new SqlCommand("up_updatewinner",oConn);
  30.                     objCmd.CommandType = CommandType.StoredProcedure;
  31.                     objCmd.Parameters.Add(new SqlParameter("@EmployeeNominationID",EomNomid));
  32.  
  33. oConn.Open();
  34.                     objCmd.ExecuteNonQuery();
  35.                     oConn.Close();
  36.  
  37. }
  38.  
  39.  
  40.         } 
  41.  
  42.  
  43.  
Aug 14 '07 #5
please any one help me with this
Aug 14 '07 #6
Plater
7,872 Expert 4TB
Your question does not seem clear.
What are you asking for exactly?
it looks like you are going through your datagrid and creating buttons.
What is the problem?
Aug 14 '07 #7
Thanks for asking sir but i already solved my problem thanks
Aug 14 '07 #8
MMcCarthy
14,534 Expert Mod 8TB
I have deleted the duplicate thread in the Milestones forum as there was nothing constructive in it.

ADMIN
Aug 14 '07 #9

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Charles Alexander | last post by:
Hello I am new to php & MySQL - I am trying to retrieve some records from a MySQL table and redisplay them. The data in list form looks like this: Sample_ID Marker_ID Variation ...
3
by: Anand Pillai | last post by:
This is for folks who are familiar with asynchronous event handling in Python using the asyncore module. If you have ever used the asyncore module, you will realize that it's event loop does not...
43
by: Gremlin | last post by:
If you are not familiar with the halting problem, I will not go into it in detail but it states that it is impossible to write a program that can tell if a loop is infinite or not. This is a...
5
by: Martin Schou | last post by:
Please ignore the extreme simplicity of the task :-) I'm new to C, which explains why I'm doing an exercise like this. In the following tripple nested loop: int digit1 = 1; int digit2 = 0;...
32
by: Toby Newman | last post by:
At the page: http://www.strath.ac.uk/IT/Docs/Ccourse/subsection3_8_3.html#SECTION0008300000000000000 or http://tinyurl.com/4ptzs the author warns: "The for loop is frequently used, usually...
2
by: Alex | last post by:
Compiler - Borland C++ 5.6.4 for Win32 Copyright (c) 1993, 2002 Borland Linker - Turbo Incremental Link 5.65 Copyright (c) 1997-2002 Borland Platform - Win32 (XP) Quite by accident I stumbled...
3
by: Ben R. | last post by:
In an article I was reading (http://www.ftponline.com/vsm/2005_06/magazine/columns/desktopdeveloper/), I read the following: "The ending condition of a VB.NET for loop is evaluated only once,...
32
by: cj | last post by:
When I'm inside a do while loop sometimes it's necessary to jump out of the loop using exit do. I'm also used to being able to jump back and begin the loop again. Not sure which language my...
16
by: Claudio Grondi | last post by:
Sometimes it is known in advance, that the time spent in a loop will be in order of minutes or even hours, so it makes sense to optimize each element in the loop to make it run faster. One of...
2
ADezii
by: ADezii | last post by:
If you are executing a code segment for a fixed number of iterations, always use a For...Next Loop instead of a Do...Loop, since it is significantly faster. Each pass through a Do...Loop that...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.