I am trying to split a collection into multiple collections while maintaining a sort I have on the collection. I have tried using the following extension method, but it breaks them incorrectly. Basically, if I was to look at the items in the collection, the order should be the same when compared to the broken up collections joined. Here is the code I am using that doesn't work:
public static IEnumerable<IEnumerable<T>> Split<T>(this IEnumerable<T> list, int parts)
{
int i = 0;
var splits = from name in list
group name by i++ % parts into part
select part.AsEnumerable();
return splits;
}
int parts = number of sub enumerables
I have a gridview that is displaying a time format like so 00:00:00 I need to split that into 3 seperate values so i can set my dropdowns to those values.
what can i search on to accomplish this.. im taking 3 drop downs and combining them into 1 value before the page is submitted.. but at a later time if you want to resubmit the form, you can pick from a list of values you have already used. so i need to take that value and split it to set the dropdowns.
I have a list of objects that I want to bind to a gridview. Creating that list and binding it works fine for most of the public properties in that list.
There are some objects contained in each of those objects... for instance there is an Address object.
object.Address.Line1;
object.Address.Line2;
When I bind this to my gridview, I have no issues with stuff like object.DateRegistered, but how can I access things like object.Address.WhatEverProperty? I always get this error:
"A field or property with the name 'xxx.xxxx' was not found on the selected data source."
I have an ASP.NET app with lots of textboxes all over the page that need updating at various points through program execution.
These textboxes actually belong to a certain class, so for easy updating I thought I could create a Dictionary(Of string, object) and add the control.ID and the control to it and then for updating do something like this:
(in case of updating textbox.text):
[code]....
However the text property of the textbox does not actually get updated. I'm mainly trying to avoid having to manually do textbox.text = somestring for each one of my textboxes every time I have to update them.
I try to compare Datetime.Now with a Datetime variable I set, using the Datetime.CompareTo() method. I use a timer to compare these every second and display the result, but as the current time approaches the time I set, the result changes from 1 to -1, but never 0, which means these two are never equal. I'm suspecting the Datetime structure contains milliseconds?
I have a simple method which takes an Object and return string "No" or "Yes". Basically I want to display "Yes" or "No" when a bool value of 0 or 1 is there
But everytime there is a 1 passed to the CheckValue which in the debug shows as true, It never evaluates being equal to "true" what am I doing wrong? My Checkvalue is always returning "No" no matter what I pass.
I'd like to be able to achieve this same functionality except to fire when the desired index IS NOT set. I cannot simply create a bunch of Conditions for each index other than the one I specify due to the way this is dynamically being done in my application.
I keep getting an error:Index (zero based) must be greater than or equal to zero and less than the size of the argument list.y code:
OdbcCommand cmd = new OdbcCommand("SELECT FirstName, SecondName, Aboutme FROM User WHERE UserID=1", cn); OdbcDataReader reader = cmd.ExecuteReader(); while (reader.Read())
I'm facing a problem that Google couldn't solve yet!I'm trying to store URLs in an XML file. Problem is that these URLs contain Equal Signs (=) in them. And that generates an error.Here is my code: (**token is a variable that contains the URL)
Dim child As String = vbCrLf & "<Link URL='" & token & "'></Link>" Dim fragment As XmlDocumentFragment = doc.CreateDocumentFragment fragment.InnerXml = child
The error message: (Error line and position are meaningless here) '=' is an unexpected token. The expected token is ';'. Line 2, position 133.I've replaced all '&' symbols with '&' in case they were the ones causing the error, but no luck so far.
I know that if I have set a cookie on a previous request, it will show up in my Request.Cookies collection. I want to update my existing Cookie. Are the cookies from my Request.Cookies collection already copied to my Response.Cookies collection? Do I need to add a new cookie with the same key using Response.Cookies.Add(), or do I need to use Response.Cookies.Set()?
I have a basic web form with about 5 textboxes. One Textbox is "Date1" and the other is "Date2." Is there a way to set the value of Date1 = Date2 after the user enters a value into the Date1 textbox? I'm using Visual Studion and C#. I'm not much of a programmer, so the less technical the better.
I'm trying to pass post data from one page to the next but PreviousPage always equals null.This is what I have in the original page (inside an updatepanel
I have ASP .NET page, and VB module. I have DropDownlist in the ASP page that retrieve information from SQL database. I am trying to make a string varaible equal the value of the dropdownlist selected.
If I want to validate that a text box contains an integer greater than or equal to zero. Do I need to use TWO asp:CompareValidator controls: one with a DataTypeCheck operator and one with a GreaterThanEqual operator?
Or is the datatype operator redundant? Can I just use a single validator with the GreaterThanEqual operator (and the type set to Integer)?
I'm using HttpModule to capture requests to the web server. Before processing the page I'd like to check the values contained in some keys of the Request.Form collection and according to some logic change if necessary. I'd like to do this when BeginRequest event is fired. The problem is that the Request.Form collection is readonly.
Dim intusercount As Integer = 0 Using connection As New SqlConnection("Data Source=.SQLEXPRESS;AttachDbFilename=|DataDirectory|Database.mdf;Integrated Security=True;User Instance=True") Using command As New SqlCommand("SELECT [ID] FROM [Members] WHERE [Username]=@Username AND [Password]=@Password", connection) command.Parameters.Add("@Username", Data.SqlDbType.VarChar).Value = TextBox1.Text command.Parameters.Add("@Password", Data.SqlDbType.VarChar).Value = TextBox2.Text connection.Open() intusercount = command.ExecuteScalar connection.Close() If intusercount > 0 Then MsgBox("Good") Else MsgBox("Bad") End If End Using End Using Error:
The data types text and varchar are incompatible in the equal to operator.
Source Error: Quote:
Line 11: command.Parameters.Add("@Password", Data.SqlDbType.VarChar).Value = TextBox2.Text Line 12: connection.Open() Line 13: intusercount = command.ExecuteScalar Line 14: connection.Close() Line 15: If intusercount > 0 Then
So admitingly I am fairly new at .NET...I have been a PHP guy for rather long time...
Heres my code:
[code]....
Essentially what I am trying to do is query the SQL database by the username. This above code is a method within the user respository for fetching a user by their username. The variable "username" is passed in as a string.
When the method is called a recieve the following error:
The data types text and varchar are incompatible in the equal to operator.
This to me is rather confusing since the field in the database, user_username, is a text and the variable passed in, as said, is a string. They should be synonomous for all practical purposes.