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
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.
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:
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:
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
I am in process of developing a registration website for a convention for work. When people register they can choose an activity to do on the convention, however some activites have a maxmium number of people. In my activity table in the database i have the following fields;
RecordID, Name, Limit, Booked, Status
So the record ID is automatic, the name is the name of the activity, limit is the maximum number that activity can hold (20), booked will have the value of the number registered for the activity and status is either open or closed. If closed the activity does not show up for the people to register.
I am not sure how to have an UPDATE query running when the person registers it UPDATES the activity database with the value in BOOKED + 1 and once BOOKED EQUALS LIMIT the status changes to Closed.
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?
As described above my session variables seem to be disappearing when i change the ActiveTabIndex of my TabContainer.
I call the session variable twice. The first time populates a div in "divResults", and then i switch to that tab, its only after the switch when i try to return the session variable again that its gone.
Is this really the case? I have seen it eluded to somewhere, and there was meant to be a fix coming out (this was 2006 or something).
Is there anything i can do here? I cant find any other reason why they would be disappearing other than this!
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
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 ?
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;
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?
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.
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#.
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.
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.
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')
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
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.
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