Changing Increment Variables Causes For Loop To Go Over Limit?

Mar 8, 2011

In my loop I am trying to remove items from a list that have a certain name. I can't do this with a for-each, so I tried a regular for-loop. It seems the for loop is not working as expected. It always goes over the limit. I had to put an if-then to break out of the loop (very ugly solution). I'm trying to find the correct way to accomplish this.

[code]...

View 3 Replies


Similar Messages:

Can't Change Increment Variables Causes For Loop To Go Over Limit?

Nov 4, 2010

In my loop I am trying to remove items from a list that have a certain name. I can't do this with a for-each, so I tried a regular for-loop. It seems the for loop is not working as expected. It always goes over the limit. I had to put an if-then to break out of the loop (very ugly solution). I'm trying to find the correct way to accomplish this.

Dim canShowNextTable As Boolean = False
Dim allTablesInTab As List(Of Control) = ctrlFinder.GetTypeOfControls("Table", parentForm.Controls)
Dim totalTables As Integer = allTablesInTab.Count - 1
For i As Integer = 0 To totalTables

[Code].....

View 1 Replies

How To Increment Anchor Tag Id Inside For Loop

Mar 25, 2011

how to increment anchor tag id inside for loop.

View 4 Replies

Loop Through All Protected Variables?

Oct 12, 2010

I have on top of my page something like...

Protected String1, String2, String3, String4 as String

Is there a way where I can loop through all of them? A way that I don't have to reference their name.

View 1 Replies

Is It Possible To Use The For Loop Counter In VB To Change The Variables Being Referenced Each Time

Nov 25, 2010

We have a project that needs to gather survey data. On one particular page of the website, there are 21 questions each with a scale of 1-5 where the user selects one radio button for each question in the table.

The survey is being coded in VB.NET. The data submits to an SQL database. All the radio buttons are similarly named, so only the number changes for the question -- thinking this would make it easier on the back end coding. In the code behind I was hoping to do something to the effect:

[code]...

View 1 Replies

Use The Loop Counter In VB To Change The Variables Being Referenced Each Time?

Jan 11, 2010

We have a project that needs to gather survey data. On one particular page of the website, there are 21 questions each with a scale of 1-5 where the user selects one radio button for each question in the table.

The survey is being coded in VB.NET. The data submits to an SQL database. All the radio buttons are similarly named, so only the number changes for the question -- thinking this would make it easier on the back end coding. In the code behind I was hoping to do something to the effect:

For i = 1 To 21
If rbLWHFQ_Q(i)A1.Checked Then
myCommand.Parameters.AddWithValue("@LWHFQ_Q(i)", rbLWHFQ_Q(i)_A1.Value)
ElseIf rbLWHFQ_Q(i)_A2.Checked Then
myCommand.Parameters.AddWithValue("@LWHFQ_Q(i)", rbLWHFQ_Q(i)_A2.Value)
ElseIf rbLWHFQ_Q(i)_A3.Checked Then
myCommand.Parameters.AddWithValue("@LWHFQ_Q(i)", rbLWHFQ_Q(i)_A3.Value)
ElseIf rbLWHFQ_Q(i)_A4.Checked Then
myCommand.Parameters.AddWithValue("@LWHFQ_Q(i)", rbLWHFQ_Q(i)_A4.Value)
ElseIf rbLWHFQ_Q(i)_A5.Checked Then
myCommand.Parameters.AddWithValue("@LWHFQ_Q(i)", rbLWHFQ_Q(i)_A5.Value)
ElseIf rbLWHFQ_Q(i)_A6.Checked Then
myCommand.Parameters.AddWithValue("@LWHFQ_Q(i)", rbLWHFQ_Q(i)_A6.Value)
ElseIf rbLWHFQ_Q(i)_A7.Checked Then
myCommand.Parameters.AddWithValue("@LWHFQ_Q(i)", rbLWHFQ_Q(i)_A7.Value)
ElseIf rbLWHFQ_Q(i)_A8.Checked Then
myCommand.Parameters.AddWithValue("@LWHFQ_Q(i)", rbLWHFQ_Q(i)_A8.Value)
ElseIf rbLWHFQ_Q(i)_A9.Checked Then
myCommand.Parameters.AddWithValue("@LWHFQ_Q(i)", rbLWHFQ_Q(i)_A9.Value)
ElseIf rbLWHFQ_Q(i)_A10.Checked Then
myCommand.Parameters.AddWithValue("@LWHFQ_Q(i)", rbLWHFQ_Q(i)_A10.Value)
End If
Next i

My research tells me that it's not possible to do what I am wanting without some special coding. I've seen mention of arrays in relation to these types of questions elsewhere, but I'm not familiar enough with arrays to see how they would work in this case.

Am I just going to have to create 21 sets of If...Else statements? :(

Here's what the HTML looks like for a question, if that matters:

<tr class="statement220">
<th><label for="rbLWHFQ_Q1_A1">1. Causing swelling in your ankles or legs?</label></th>
<td title="0" >
<input id="rbLWHFQ_Q1_A1" name="rbLWHFQ_Q1" type="radio" value="0" runat="server" />
</td>
<td title="1" >
<input id="rbLWHFQ_Q1_A2" name="rbLWHFQ_Q1" type="radio" value="1" runat="server" />
</td>
<td title="2" >
<input id="rbLWHFQ_Q1_A3" name="rbLWHFQ_Q1" type="radio" value="2" runat="server" />
</td>
<td title="3" >
<input id="rbLWHFQ_Q1_A4" name="rbLWHFQ_Q1" type="radio" value="3" runat="server" />
</td>
<td title="4" >
<input id="rbLWHFQ_Q1_A5" name="rbLWHFQ_Q1" type="radio" value="4" runat="server" />
</td>
<td title="5" >
<input id="rbLWHFQ_Q1_A6" name="rbLWHFQ_Q1" type="radio" value="5" runat="server" />
</td>
</tr>

As an aside, I know about RadioButtonLists, but in this case I'm needing to style the radio buttons in a special way and can't get it to work when ASP renders the list items.

Updated to show I used it in my code I'm not sure how StackOverflow works with regards to showing how something worked for you, but I just wanted to add this in case others come here looking for the answer. Basically, I used the code below:

Dim radioButtons()() As HtmlInputRadioButton = { _
New HtmlInputRadioButton() {rbLWHFQ_Q1_A1, rbLWHFQ_Q1_A2, rbLWHFQ_Q1_A3, rbLWHFQ_Q1_A4, rbLWHFQ_Q1_A5, rbLWHFQ_Q1_A6}, _
New HtmlInputRadioButton() {rbLWHFQ_Q2_A1, rbLWHFQ_Q2_A2, rbLWHFQ_Q2_A3, rbLWHFQ_Q2_A4, rbLWHFQ_Q2_A5, rbLWHFQ_Q2_A6}, _
}

I created an array with the radio button group names:

Dim radioButtonGroupNames() As String = { _
"@LWHFQ_Q1", _
"@LWHFQ_Q2", _
}

Then in my For...Loop I used:

For i = 0 To 20
If radioButtons(i)(0).Checked Then
myCommand.Parameters.AddWithValue(radioButtonGroupNames(i), radioButtons(i)(0).Value)
ElseIf radioButtons(i)(1).Checked Then
myCommand.Parameters.AddWithValue(radioButtonGroupNames(i), radioButtons(i)(1).Value)
ElseIf radioButtons(i)(2).Checked Then
myCommand.Parameters.AddWithValue(radioButtonGroupNames(i), radioButtons(i)(2).Value)
ElseIf radioButtons(i)(3).Checked Then
myCommand.Parameters.AddWithValue(radioButtonGroupNames(i), radioButtons(i)(3).Value)
ElseIf radioButtons(i)(4).Checked Then
myCommand.Parameters.AddWithValue(radioButtonGroupNames(i), radioButtons(i)(4).Value)
ElseIf radioButtons(i)(5).Checked Then
myCommand.Parameters.AddWithValue(radioButtonGroupNames(i), radioButtons(i)(5).Value)
End If
Next i

View 2 Replies

C# - Setting Private Memory Limit For Application Pool In IIS 7 Increased Page Faults Before Crossing The Limit

Aug 16, 2010

I have set Private Memory limit of 200mb in IIS 7 for an application pool. The Private Working Set memory(Task Manager) for the application is always below 125mb but the number of page faults have increased a lot and application cache is getting cleared frequently after setting the limit.

I haven't set any limit on Virtual Memory.why the cache is getting cleared even when the Private memory used is below the allocated memory?

View 1 Replies

Collect 2 Variables From One Hyperlink, And Use Those Variables In The Page_load To Set As Session?

Aug 8, 2010

i am trying to collect 2 variables from one hyperlink, and use those variables in the page_load to set as session. but i don't know how to collect those 2 variables

such :

<a href="javascript:;" onclick="wsChangeColor('mainData', '#FF0000','#FFE4E1');return false;" title="Change color" id="red">1</a>

i would like to collect '#FF0000','#FFE4E1' or direct set '#FF0000','#FFE4E1' to string then send to pageload, how can i do this by only clicking on it ?

View 1 Replies

Web Forms :: Storing Javascript Variables Into C# Variables

Jan 2, 2010

I have this code in javascript: var x = e.mapX; It gets the X-coordinate of a map. What I want to do is that I want to store this into a c# variable. I have a class named Test with an integer property X. I want to store var x into X. In the codebehind, I have this on the Page_Load: Test test = new Test(); Then I am trying this on the javascript code: var x = e.mapX;

View 16 Replies

Delaring A String Thats Within A Loop Within Another Loop

Jan 14, 2010

Im stuck with declaring a string which is in a loop within another loop.

Dim CompanyDetails As String = ""
Dim CompanyRow As DataRow
For Each CompanyRow In newdt.Rows
CompanyDetails += CompanyRow(1) & " " & CompanyRow(0) & "<br/>"...

How can I get this to see the GetInfo as declared..... since its in a loop within a loop?

View 9 Replies

Working With Static Variables / Store The User Specific Information In Static Variables?

Mar 5, 2011

whats the exact use of static variables in overall programming in .net and for asp.net...

Recently i went for the interview where interviewer asked me 2 question which i was not sure for the same..

whats the use of session object, i said sessions are the server side object, they are used when you want to store user specific data at server side, then he asked what if i want to use static variables for the same, i was mum, can anyone tell me how asp.net will behave if i store the user specific information in static variables.If i use cookies which are the best option to store the data at client side (not sensitive one), but what if user has disabled cookies on his machine, will my application would crash.

View 3 Replies

State Management :: Session Table Value Also Changing When Changing Any Coloumn Name?

Jan 10, 2011

The problem is when am assigning my session table value to newly created table and if now am changing any coloumn name then the session table value also changing.

But my question is am assigning Session value to newly created table so how should session value should be affected?

for refference in my application

sessionState
mode="InProc"

View 5 Replies

Increment Value In Textbox

Jul 4, 2010

Of course, every registration needs a primary key like a registration number. I have a textbox that is visible(for now) and I need to have the value inside it(100001) to increment by 1 for each different registrations. How do I achieve this? I need it in C#.

View 16 Replies

Mvc Increment Values?

Jul 22, 2010

I have values like 4IT/IT1,i want to update this values like below -

if it is 4IT/IT1 then increment it by 1

so it will be 5IT/IT2 so on...

View 11 Replies

Web Forms :: How To Increment Just The Decimals

Apr 15, 2010

I have a text box, if i have 1.00.

Then in the textbox1.text it should be 1.01

if i have 1.01 then it should be 1.02

How to increment 10th of a decimals by 1.

View 3 Replies

MVC :: Unable To Increment A Value While Using ViewData?

Apr 7, 2010

The functionality I'm looking for is really simple. I'd like to increment a an integer called
index. Each time I click a button, I post a form to an action method, which increment index and redisplay the view with the new value of the index.

So, I've 2 action methods called Increment (Get and Post versions ):

Increment (GET) action method displays the View, supplying also an initial value of index through the ViewData.

[Code]....

When I click to the button "increment" on the view, I post a form to Increment (POST). The value from the ViewData is sent back to the Controller through an "Hidden field" [Code].... Increment (POST) action method pulls the the value of the index, increments the value, and sends back the new value of index through ViewData when it re-displays the view.[Code]....

Unfortunately, all I can get is ONE increment. in the case above, I get 2. after that, I keep getting 2. If I change the value to 2, I get 3 and nothing else, etc... I suspect that ViewData, once it has gotten a value, keeps it forever.

View 8 Replies

Auto Increment The Record Number?

Apr 29, 2010

i am using one text box in New registration page. when ever user clicks on New registration button, The text box of record number should be auto incremented.

View 12 Replies

C# - Inserting Row Into Table With Auto Increment Value?

Mar 23, 2011

I got a table PartsMedia where I can insert all the images related to a product. The table has the columns :

PartsMediaID , auto-increment
PartsNo
MediaLink
MediaDescription
CatalogCode
SortCode

I want to insert a complete row with automatic increment and the PartsNo should be the same as the PartsNo from the PartsMaster table.

The medialink should be the PartsNo + '-2.jpg'
The mediadescription is for example 'image2'
The CatalogCode should be 'catalog'
and the sorting code should be '0'

From The partsMaster table I Just need the PartNo So I can add this to the PartMedia Table. The PartNo is the foreign key in the PartMedia table.

The following I got so far but no luck

insert into dbo.PartsMedia (PartNo,MediaLink,MediaDescription,CatalogCode, SortCode)
values (dbo.PartsMaster.PartNo, PartsMaster.PartNo+'-2.jpg','image2', 'catalog','0')

View 3 Replies

Auto Increment Feature In Database?

Nov 2, 2010

I use SQL Server and when I create a new table I make a specific field an auto increment
primary key. The problem is some people told me making the field an auto increment for the primary key means when deleting any record (they don't care about the auto increment field number) the field increases so at some point - if the type of my field is integer for example - the range of integer will be consumed totally and i will be in trouble.

So they tell me not to use this feature any more.The best solution is making this through the code by getting the max of my primary key then if the value does not exist the max will be 1 other wise max + 1.Any suggestions about this problem? Can I use the auto increment feature?I want also to know the cases which are not preferable to use auto increment ..and the alternatives...note :: this question is general not specific to any DBMS , i wanna to know is this true also for DBMSs like

View 6 Replies

DataSource Controls :: Increment Non ID Column In SQL?

Jul 8, 2010

I have a simple list of data in my database that I call to my page. I have used the asp.net 'reorder list' ajax control to provide a drag and drop way of managing the sort order of my data. It uses a 'position' column in the database to do this.

How do I go about making sure that when inserting data to this table, the new item gets assigned the correct 'position' value? For example if I have 9 items already in my table, I want this newly inserted list item to get assigned a value of 10 in the position column.

View 5 Replies

Increment The Variable While Page Loading?

Jan 5, 2011

incremnet the variable while page loading each and every time

View 4 Replies

ADO.NET :: Get Auto Increment Field After Inserting?

Dec 6, 2010

I'm adding a couble of fields to database but i need the primary key of the master table to add it to sub table.

The database contains 2 tables :

Question Table :questionID(primary key and identity) , questionInText

Answer table : answerID , answer1,answer2 , questionID

code used to insert to db :

[Code]....

questionID is auto increment.

The question is : How i get questionID after adding to database without using sql statment ?

View 1 Replies

Web Forms :: Add Increment ID At The Place Of Lead ID?

Apr 27, 2016

i want to add an increment id at the place of Lead_ID

<img src="http://track.opicle.com/aff_l?offer_id=2193&adv_sub=Lead_ID" width="1" height="1" />

View 1 Replies

Controls :: How To Increment A Value On Button Click

Mar 17, 2014

can i count data entered?

current page only can be proceed to next page only if user entered 2 set of data.

i use count=count + 1

but everytime i enter new data the count back to 0

this is my code

If msg <> "" Then
MessageUser(msg.Substring(0, msg.Length - 1) & "must have value.")
Else
If clsRecruit.NewReference(hd_personid.Value) = True Then
counter = counter + 1
getReference()
txtbox_name.Text = ""
txtbox_residence.Text = ""
txtbox_mobile.Text = ""
txtbox_email.Text = ""
txtbox_job.Text = ""
End If
End If

View 1 Replies

Data Controls :: Increment Value From DropDownList

Dec 23, 2013

I have on dropdown list which is bound with database in dropdown list there are months and year i want to do that when i select one data from dropdown list then it should be incremented by 6 and display in text box 

For example

I select January 2013 then in text box July 2013 should be displayed...

View 1 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved