Nested Loops - Moving To Next Record In While Loop At Any Time?
Mar 25, 2010
Not sure why this is messing with my brain so much today, but I have a SQLDataReader that loops through "Customer" records. In each loop there are MANY other conditions that need to be validated. When a condition fails I want it to move on to the next record in the reader. As you see from my code below, I have simply been exiting the for loop and then checking if I should run other loops all the way down. I want to simply move back to the top of the While Loop for another pass when something like this happens:
[Code]....
View 3 Replies
Similar Messages:
Sep 3, 2010
I doing a nested for loop to achieve from #123,33.5,1283485089#44.6,Timestamp#124,66.7,timestamp#55.7,timestamp#125,76.4,timestamp#42.8,timest amp whole string to #123,33.5,1283485089#123,44.6,Timestamp#124,66.7,timestamp#124,55.7,timestamp#125,76.4,timestamp#125 ,42.8,timestamp. My code get me back same thing again
Dim i = 0
Dim rsplitdata As String()
Dim row, item As String
Dim inex
Dim rdata As String() = TextBox1.Text.Split("#")
For Each row In rdata
rsplitdata = row.Split(",")
If (i = 0) Then
inex = rsplitdata(0)
'rdata(i) = inex + "," + rdata(i)
Else
rdata(i) = inex + "," + rdata(i)
End If
i = i + 1
Next
For Each row In rdata
rsplitdata = row.Split(",")
For Each item In rsplitdata
TextBox2.Text = TextBox2.Text + item.ToString + vbCrLf
Next
Next
View 3 Replies
Apr 29, 2010
I cant get my nested loop to output the right code:
If pagesreader.Read() Then
' if subtitle exists then output
mydata = "<h2>" & pagesreader.Item("documentcategoryname") & "</h2>"
While pagesreader.Read()
mydata &= "<h2>" & pagesreader.Item("documentcategoryname") & "</h2>"
If (pagesreader.Item("documentcat") = pagesreader.Item("documentcategoryid")) Then
mydata &= "<p>" & pagesreader.Item("documentname") & "</p>"
End If
End While
End If
produces:
About Us
About Us
doccy4
Map Of Medicine
doccy5
When I need it to procude:
About Us
doccy3
doccy4
Map Of Medicine
doccy
View 7 Replies
Dec 31, 2010
I try to access to the fields of each single record in the table without writing the specific name of the field,
For example , checking each property of the record whether it's null or not,
something like that:
var myUser = from u in dataContext.Users
select u;
foreach (User item in myUser)
{
// Here I wand to access to the fields by their ordinal number.
}
View 2 Replies
Jan 3, 2011
DataClasses1DataContext dc = new DataClasses1DataContext();
var q =
from a in dc.GetTable<Order>()
where a.CustomerID.StartsWith("A")
select a;
}
i have run this query but through using dataGridView1.DataSource = q;
i have get the out put
but i want to select each record through loop because i want to store it in variable
View 2 Replies
May 17, 2010
i have a website that needs to retrive some records in the database, to be specific, example is their Email Address, its more or less 10 records out of 100 records in a table but that number changes from time to time. upon retriving their Email Address, i need to Email them some messages one email at a time.
So to summarized it all:
1. Retrive data from a table (Email Address)
2. Make a Loop on each Email then send Message one email at a time.
give me a sample codes for the retriving and looping process?
View 2 Replies
Aug 11, 2012
I am making one application where i am fetching huge data from database to gridview.
for this it was taking some 30 to 40 seconds. so instead of showing nothing in the page
I am using update panel and update progress bar.
everything is ok but when progress image is showing in the page that time it's moving only one time and stop and before completing page postback.
Here is my code:
<asp:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server">
</asp:ToolkitScriptManager> <div><script language="javascript" type="text/javascript">
var prm = Sys.WebForms.PageRequestManager.getInstance();
var popup = $find('<%= modalPopup.ClientID %>');
prm.add_initializeRequest(InitializeRequest);
[Code] ....
And here is my code behind:
protected void Button1_Click(object sender, EventArgs e) {
con.Open();
SqlCommand com = new SqlCommand("select * from processdailydata", con);
SqlDataAdapter sda = new SqlDataAdapter(com);
DataSet ds = new DataSet(); sda.Fill(ds);
GridView1.DataSource = ds; GridView1.DataBind(); con.Close(); }
i want to show progress image move regularly untile page load is not finished.
View 1 Replies
Oct 30, 2010
Scenario : I have two database tables with one to many relationship. eg:- City and Related news. So I have a gridview(Gridview1) which lists out all the cities and allows edit, delete of the gridview rows. Now since i wanted to display all news for the city, i have a nested gridview as a column in this Gridview1. This nested gridview displays all the news for the cities. And I have edit, delete buttons for this gridview too - So far, good - works fine.
Now what I would like to do is - To insert a new news item for a city. For this, I attached a detailsview to my nested grid(gridview2), and tried to insert. I need the primary key id of city table from the first grid (gridview1) to insert the news into the second database table and I could not access this value from the parent gridview. My gridview1 does not have datakeyname, it is programatically bound.
Also, When the gridview/detailsview is nested, it does not get listed in the event-handler list. So I cannot use say, detailsview1_iteminserting. I do not how to add this event handler
Has anybody done anything similar? When I started, it looked like a pretty straightforward thing - There must be some way to do this. But I just can't get it to work. How do you usually insert into the child table in a one-to-many relationship? Should i just be using two separate gridviews?
View 5 Replies
May 4, 2014
I have a GridView1 With Paging allowed, PageSize = 10. And a Nested GridView2. The INSERT function on nested GridView2 works well until the number of record is 10.
On inserting the 11th record, the GridView1 is recorded normally in page 2 of 2. The Nested GridView2 does not fired properly. it appears empty on the 11th record (page 2 of 2), but instead add its record on the last recorded ID on page 1 of 2.
When I remove the paging, everything works well.
How to resolve the paging issue with Nested GridView on "INSERT" record?
View 1 Replies
Jan 21, 2011
I have got a test page setup trying to figure out and learn how to nest gridview.. i finally have a working configuration,but my issue now is that if i select a record from my gridview,the nested gridview opens as expected.But when i select another record from the list in the parent gridview the first selection i made stays open and as i pick more and more, all the nested gridviews stay open.Is there something i can do within my
GridView1_SelectedIndexChanging event to hide the previous gridview and display only the selected row gridview?
View 11 Replies
Dec 22, 2010
Do all comet style applications require a loop somewhere in the application on the serverside to detect updates/changes? how the logic behind a loopless comet style application would work?
View 3 Replies
Jan 21, 2011
I am building a small mass email application for my department. Which basically emails out a notice to a large list of email addresses. Because the company email server limits the amount of email addresses that can be contained in a single email I have to break the list apart into smaller 100 email groups.
I've create the query to pull all email addresses needed, stuffed them into a collection but I am not sure how to grab 100 emails at a time and send it off to another sub to perform the email send before grabbing the next 100.
This is what I have so far.
[Code]....
View 5 Replies
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
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
Feb 4, 2011
I'm trying to on Page_Load hide all my RadioButtonLists but I can't seem to get the syntax quite right
I'm guessing I've got to use the FindControl syntax something like this
CType(FindControl, RadioButtonList)
And then I'm guessing I will have to loop through each RadioButtonList and set the Visible = False attribute on it.
I seem to be getting an error with the code above.
View 4 Replies
Mar 17, 2011
I need to perform update operation in a datatable without using loops. Is there any way to perform update in a datatabel...
View 3 Replies
Dec 18, 2010
I am having a change password page in that when the user change his password and click on submit i will show a message and will redirect to main form. But the text which i like to display is not displaying. What i need is i would like to have the page in the same form for few amount of time and then redirect to the desired one.
<script type="text/javascript">function LoadPage()
{
var v =setTimeout("MovePage()",5000); //will call the MovePage() function after 5 seconds
}
function MovePage()
{
location.href='/FedData/newRoutingNumbervalidator.aspx';
}
</script>
View 2 Replies
Jan 18, 2011
This code cause double record... i checked my insert code for all tables and it works fine...
and this is insert code:
StoreDO store = new StoreDO();
List<BrandDO> brandList = new BrandBL().SelectBrands();
StoreBL storeBL = new StoreBL();
store.StoreName = txtStoreName.Text;
[Code]....
View 1 Replies
Jan 24, 2011
I am working with asp.net 2008 and sql server 2005 . I get a situation where i have to delete data after 30 days. a suitable query how to do the same. I have go through different query but nothing going right for me.
View 2 Replies
Sep 14, 2010
easiest way to create/update a parent and child record at the same time (like customer with multiple addresses) with least or no code as possible? Both Web Forms and in MVC.
View 1 Replies
Jul 1, 2010
I am querying the SQL database table and returning the result on the webform with a repeater, but I need to display one record at a time and refresh with an update panel and timer to iterate through the rows of the table one at a time at a fixed interval.
Is there another solution to be able to display one record at a time using c# in the webform, but then cycke through the other records one at a time using a timer control and updatepanel?
View 5 Replies
Dec 31, 2010
I tried with no succcess doing a search here on the forum for some answers or pointers. So here goes.
I would like to Calculate total time from a records in a table.
the Table we'll call it "Time Table" may have four rows IE.
Field1 Field2
IN 08:00:00
OUT 12:30:00
IN 13:00:00
OUT 17:00:00
I am trying to display these records in a Child gridview with a total. Is there any SQL that can total time like this? or any other way I can total this?
View 7 Replies
Nov 12, 2010
I've got a DetailsView control on the page, which includes a FileUpload control. Both parts work individually e.g. I can upload a file and insert a record but what I'd like to be able to do is do both with one click - either on the Upload Buttton or on the Insert record text.
I have a button click event:
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
But I'm not sure how to call the Insert Record event on the detailsView control.
View 6 Replies
Sep 15, 2010
In my online web-application User is inserting new records and when user enters record system gets current datetime (using below query) and insert into table.
INSERT INTO Gponmig(Customer_Name, Contact_Mob_No, Sector, Plot, flat, Building_LandMark, Sr_No, Adsl_Acc_No, Del_Acc_No, Mig_Requirment, Reseller, Sales_Remarks, Userid, Dept, Date)
VALUES (@Customer_Name,@Contact_Mob_No,@Sector,@Plot,@flat,@Building_LandMark,@Sr_No,@Adsl_Acc_No,@Del_Acc_No,@Mig_Requirment,@Reseller,@Sales_Remarks,@Userid,@Dept,
GETDATE())
Problem:
User entered data at 12:27 PM but system recorded 12:27 AM.
I couldn't find why?
It is confirmed by the user that he didn't worked midnight.
Required:
The system should insert correct time.
View 5 Replies
Sep 2, 2010
When I try to insert a record the Filing Date and Report Time fields are always blank in the database.
View 5 Replies