Iterating DataView For Update?

Jul 18, 2010

I have a DataView which filters

inputView.RowFilter = "isnull(" + ID1 + ",'')<>'' and isnull(" + reason + ",0)=0";

after this filter i have to update "IsVerified" column of inputView to "1"

Is there something in LINQ to execute the following?

inputView.RowFilter.ForEach(x=>x.Field<IsVerified> =1);

View 1 Replies


Similar Messages:

C# - Iterating Through TextBoxes - Not Working?

Nov 3, 2010

I have 2 methods I tried to iterate through all my textboxes in an asp.net page. The first is working, but the second one is not returning anything. Could someone explain to me why the second one is not working?

This works ok:

[code]....

View 3 Replies

C# - Iterating Through A Listview For Specific ID?

Jan 20, 2010

I've got some labels in a listview, 2 per row. One contains a title, the other information. I want to change all the titles when the user presses a button that fires the ListViewSelectEventArgs. I think they have the same ID since they're from the ItemTemplate, so I thought that's how'd I target them. I'm just not sure how I'd step through the listview.

Here's my attempt:

int x = 1;
for( int i = 0 ; i < this.lvSteps.Controls[0].Controls.Count; i++ )
{
if ( this.lvSteps.Controls[0].Controls[i].GetType() == typeof(Label) &&
( this.lvSteps.Controls[0].Controls[i].ID == "lblStepNumber" ||
this.lvSteps.Controls[0].Controls[i].ID == "lblNewStepNumber" ) )
{
Label lbl = this.lvSteps.Controls[0].Controls[i] as Label;
lbl.Text = "Step #" + x;
x++;
}
}

View 1 Replies

MVC :: Iterating Through Form Elements With Same Name?

Mar 21, 2011

Currently, I have a list of PhoneNumber objects that I display. Here's an example of the output of the view:

[Code]....

Notice the naming of these elements: name="existing_phone[labels][6]", name="existing_phone[numbers][6], name="new_phone[labels][]", name="new_phone[numbers][].Back in the Classic ASP days, I recall being able to do something along the lines of:

[Code]....

And that would give me a 2d array of phone numbers to work with. This doesn't seem to work in .NET. Has anyone tried to do something similar that can point me in the right direction?For new phones, I should simply be able to iterate through each item and insert into the database. For existing phones, I should be able to update (or delete if the label or number are blank) records based off of the id number supplied in the array.OR..if anyone has a better, alternate solution, I'm open to something else.

View 5 Replies

Iterating Through Regex Matches?

Mar 2, 2010

I have a string of information that I need to parse. I've written a regular expression to find the information I need. Now how would I iterate through each regex match and add it to a list (or do something to it)?

View 2 Replies

ADO.NET :: Iterating Through Rows In A Table Without Using GridView

Feb 25, 2011

how to iterate through the rows in a database table without using a GridView? I have a DataSet and a SQLDataReader, but I can't iterate through rows using the SqlDataReader.

View 13 Replies

System.InvalidCastException Iterating Through Viewdata

Jan 19, 2011

System.InvalidCastException iterating through Viewdata

I need to replace the code
"<%=Html.DropDownList("Part", (SelectList)ViewData["Parts"])%>"
for dropdown in the following manner for some reason.
<% foreach (Hexsolve.Data.BusinessObjects.HSPartList item in (IEnumerable)ViewData["Parts"])
{ %>
">
<%=item.PartName %>
<%=item.IssueNo %>
<% } %>

I am getting error converting SelectedList to IEnumerable) Error: Unable to cast object of type 'System.Web.Mvc.SelectList' to type 'System.Collections.Generic.IEnumerable`1[Hexsolve.Data.BusinessObjects.HSPartList]'. Is this the right way to iterate through viewdata[].

View 1 Replies

Php - Keep Sql Connection Open For Iterating Many Requests?

Jan 26, 2011

this is general to any operation calling an SQL server, or anything requiring an open connection at that.Say I have anywhere from 20 to 1000 Select calls to make for each item in data being looped. For each step, I'll select from sql, store data locally in a struct, then proceed. This is not a very expensive call, so should I keep the connection open for the entire loop? Or should I open and close every step? How expensive in run time is opening a connection? I would think it'd be better to keep the connection open, but would like to get the correct response for this.

View 4 Replies

C# - How To Remove Rows From Huge Data Table Without Iterating It

Jan 28, 2011

I have a DataTable available with me which contains thousands of rows. There is a column called EmpID which is containing '0' for some of the rows. I want to remove them from my current DataTable and want to create a new correct DataTable. I cannot go row by row checking it since it contains huge amount of data.

View 6 Replies

Forms Data Controls :: Iterating Through Datalist Working Except Last Row?

Jan 22, 2010

I have some code that iterates through three datalists when they are bound and looks for certain values. If those values exist it hides that particular row in the Datalist. This is working beautifully, except the last row in each datalist is unaffected by the iteration. So for example if I have the following numbers 2, 5, 6, 5, 7, 5 and I want to hide all the rows that contain 5, it produces the following: 2, 6, 7, 5.

Here is my code:

Dim dlitem As DataListItem
Dim tb1 As Label
For Each dlitem In OnHoldDataList.Items
tb1 = CType(dlitem.FindControl("LocationLabel"), Label)

[Code]....

View 1 Replies

Iterating System.Collection.Generic.List.Add Does Not Work As Expected?

Mar 7, 2010

I was building an application for a project with .NET 3.5 and I noticed a weird behaviour of the List.Add method:

I have built my own class to organize data pulled from a database, and I use a while cycle to iterate through it.

However, when I List.Add(item), the whole content of the list is substituted with the last content pulled.

An example:

Suppose you have 3 users in a DB, each one identified with an ID and a username:

| ID | username |
| 1 | John |
| 2 | Fred |
| 3 | Paul |

and you have a "Users" class defined as

public class Users
{
private Int32 iD;
private String username;
public Int32 ID
{
get { return iD; }
set { iD = value; }
}
public String Username
{
get { return username; }
set { username = value; }
}
}

So you write this function:

[... SQL definitions - sdr is a SqlDataReader ...]
List<Users> userlist = new List<Users>();
if (sdr.HasRows) //There are users
{
Users user = new Users();
while (sdr.Read())
{
user.ID = sdr.GetInt32(0);
user.username = sdr.GetString(1);
userlist.Add(user);
}
}

What you expect (I expect) is userlist containing:

| ID | username |
| 1 | John |
| 2 | Fred |
| 3 | Paul |

What I actually get is, instead

| ID | username |
| 3 | Paul |
| 3 | Paul |
| 3 | Paul |

View 3 Replies

Forms Data Controls :: Iterating Child Grid Rows On Button Click?

Jun 29, 2010

i am having Nested Gridview and from the child Grid i have to select the checkbox to retrieve the id's by iterating the child grid and that to on the Button Clik which is outside the Gridview.

View 2 Replies

Iterator Not Iterating / Iterator Within The While Loop Returns False For The MoveNext Method?

Mar 16, 2011

I'm having trouble with something that is (or should be) fairly straight-forward.

I have a recursive method that traverses an XML file, writing out the element tag names and values.

This is a snippet from the XML file:

[code]

<root>
<all_companies>
<company_group company_group_ID_attr="1">
<company_group_name>Cleaning</company_group_name>
<company_group_ID>1</company_group_ID>
<company company_ID_attr="2">
<name>Bloomburg</name>
<company_ID>2</company_ID>
<Address>blah blah blah</Address>
<employee_refs>
<employee_ref>4</employee_ref>
</employee_refs>
</company>
<company company_ID_attr="4">
<name>Morris</name>
<company_ID>4</company_ID>
<Address>blah blah blah</Address>
<employee_refs>
<employee_ref>3</employee_ref>
<employee_ref>1</employee_ref>
</employee_refs>
</company>
<company company_ID_attr="7">
<name>Ajax</name>
<company_ID>7</company_ID>
<Address>blah blah blah</Address>
<employee_refs>
<employee_ref>4</employee_ref>
<employee_ref>2</employee_ref>
</employee_refs>
</company>
</company_group>
</all_companies>
</root>

[/code]

I use the following XPath expression to access the first <company group> tag:
"root[1]/all_companies[1]/company_group[1]"

On the first call to the recursive method ("swrite_for_select_certain_stuff"),I see with the debugger that I reach the <company_group_name> tag. A recursive call at that point takes me to the text node within the tag ("Cleaning"), but it is a text type node (not an element), so it returns without writing anything to the output stream.

On return from that second call, things go wrong. The Iterator within the while loop returns false for the MoveNext method, when it should have moved to the <company_group_ID> tag (or so I think it should).

Am I missing something here?

OS is Win XP, and .NET is version 4.0.

My code is as follows:

[Code]....

View 1 Replies

Forms Data Controls :: Iterating Through Controls In Gridview Without Using FindControl

Feb 19, 2010

I have this...

[Code]....

[Code]....

I'm doing this in my Master Page. I want to access a Linkbutton within the Gridview and set the enabled = false; I tested this and it works all the way up to the first if statement.If I insert a response.write to get the frmctrl.ID, I get all of the controls on the page. BUT, can't get the controls within the gridview.How do I get the contorls within the gridview? I prefer not to do this using Findcontorls and esp setting the control to Public.

View 4 Replies

Add One DataView To Another In C#?

Jun 22, 2010

I need to add two DataViews together to have one Dataview that can then be bound to a Repeater.

I am plugging into someone else's API so I can't change the way the data is retreived at the SQL Level.

So essentially I want to do this:

DataView dView1 = getActiveModules();
DataView dView2 = getInactiveModules();
ModuleView = dView1 + dView2;
rptModules.DataSource = ModuleView.Tables[0];
rptModules.DataBind();

The two schemas for the views are identical just retrieving active and inactive modules.

View 2 Replies

ADO.NET :: Filter Dataview Row With Top 10?

Jul 30, 2010

What I want is to filter the dataview so I get top 10.

I googled it and found out that I had first to sort the dataview. Then add a column (int) to datatable. This column I then made a AutoIncrement on......

This works fine - I can see in the codebehind that it adds a column to the datatable that I called AutoInc.

Then make a RowFilter on the dataview - here it goes "wrong" for me.....

When using the line

datVie.RowFiler = "AutoInc < 11";

and bind it to a gridview I don't get a error - but it also don't show me any rows in the gridview...... If I comment the line out - I get all the rows in the dataview..

Can anyone see in my below code what is wrong?

[Code]....

View 2 Replies

ADO.NET :: Modifying The DataView Using Linq?

Mar 1, 2011

I have a DataView resulted from a query as below

Title
Return Type
The Inception
1
NFS
2
Tron Legacy
1
Documentary
3
Roadrash
2
I want to pass this object to a method which modifies it using linq query to return the Dataview object as below(without using loops anywhere in the code)
Title
Return Type
The Inception
Movie
NFS
Game
Tron Legacy
Movie
Documentary
Others
Roadrash
Game

View 1 Replies

C# - DataTable Must Be Set Prior To Using DataView?

Jan 29, 2010

When i try to sort my table manually, i receive this error:DataTable must be set prior to using DataView.The code is:

protected void GridView1_Sorting(object sender, GridViewSortEventArgs e)
{
DataTable sourceTable = GridView1.DataSource as DataTable;

[code]...

View 2 Replies

Remove Record From A DataView?

Jan 18, 2011

I have a DataView which has been populated with a list of files from a database table. I want to iterate through the DataView to see if there are any files there of a particular type, and if so, do something with that record, and then remove it from the DataView.

I've coded this as follows, but there's something missing - I can iterate over an object and then remove an object from it, since that will affect the iterator.

DataView dv = new DataView();
dv = ds.Tables[3].DefaultView;
dlFiles.DataSource = dv;
dlFiles.DataBind();
for (int j = 0; j < dv.ToTable().Rows.Count; j++) {
if (dv.ToTable().Rows[j]["FilePath"].ToString().ToLower().Contains(".pdf")) {
//do something with this record and remove it from the dataview
}
}

As a note, dlFiles is a DataList used to display the the items in the DataView. The files removed are displayed differently, and so should not be referenced when iterating through the DataList.

View 2 Replies

Web Forms :: Convert Dataview To Dataset?

Feb 25, 2010

I have Dataset with Data table with unsorted record i used the RowFilter for Filtering the Record like below

DatasetStudent.Tables[0].DefaultView.Sort = "Column Name"

Now i have to Pass the Dataset DatasetStudent with sorted record to Report how i convert the default view to Dataset.

View 4 Replies

C# - How To Select Top Of Rows From A Datatable/dataview

May 7, 2010

How to select top n rows from a datatable/dataview in asp.net.currently I am using the following code by passing the table and number of rows to get the records but is there a better way.

public DataTable SelectTopDataRow(DataTable dt, int count)

{
DataTable dtn = dt.Clone();
for (int i = 0; i < count; i++)
{
dtn.ImportRow(dt.Rows[i]);
}
return dtn;
}

View 2 Replies

AJAX :: How To Put Modal Popup In A Dataview

Feb 3, 2010

using Previeww 6 of Ajax....

I'm attempting to put a modal popup in each row of a dataview as shown:

[code].....

but the popupcontrolid cannot be found. I have checked the Dom and it has been created but $get cannot find it.

View 2 Replies

ADO.NET :: Sorting AlphaNumeric Column In DataView?

Oct 28, 2010

I have a sorting issue with DataView.

View 2 Replies

C# - How To Sort A DateTime Column In DataView

Mar 21, 2011

I have a gridview with some columns and I need to sort the gridview by a date-column. But it doesn't sort it correctly. This is the code I use:

dt.DefaultView.Sort = "Meldingsdatum asc";
gvOutlookMeldingen.DataSource = dt;
gvOutlookMeldingen.DataBind();

View 2 Replies

Checking Number Of Rows In Dataview?

Feb 2, 2011

I want to check that the row index I specify is below the row count so it doesn't throw the error

Index 2 is either negative or above rows count.

how would I achieve this with my code?

Using connection As New SqlConnection(connStr)
Dim command As New SqlCommand
command.Connection = connection
connection.Open()
Dim a As New SqlDataAdapter("SELECT top(3) name, (SELECT TOP (1) ImageId FROM Images WHERE(productid = products.Id)) AS imageId FROM Products WHERE beginnerdiscount = '1' ORDER BY Dateadded", connection)
Dim s As New DataSet()......

View 11 Replies







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