Syntax Error During Generic List Initialization?
Apr 27, 2010I am creating a generic list of objects using this syntax:
[Code]....
I am creating a generic list of objects using this syntax:
[Code]....
The following CLR syntax works fine in my aspx page:
<%@ Page Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="Website.MyBasePage`1[HomePageViewModel]" %>
But this C# syntax does not:
<%@ Page Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="Website.MyBasePage<HomePageViewModel>" %>
Note, I am not using ASP.NET MVC, but this works fine if using System.Web.Mvc.ViewPage<> from ASP.NET MVC.
My MyBasePage looks like this:
public class MyBasePage<TModel> : Page where TModel : class {
public TModel Model
{
get { return (TModel)HttpContext.Current.Items["model"]; }
}
}
I'm trying to use a Generic list for my class but I'm getting this error "Conversion from type 'EnumerableQuery(Of VB$AnonymousType_105(Of String))' to type 'String' is not valid."
[Code]....
-imperialx
I have already stored value of author id in list item value while page loads. but when I change index of drop down list to view author information error is shown. I tried to debug using check points and it seems Sqlreader isn't reading database second time.
Incorrect syntax near '='..
Here is my code
[code].....
DataRow[] filterRows = ds.Tables[0].Select("Running Status= case State when 'True' then 'Running' When 'False' Then 'Stoped' end Where Active='1' and State='1'");
this is not working showing syntax error syntax error:operand is missing
I'm having problem in inserting text from a textbox in which user write or copy some text which may contain special characters ( " , . ) etc. If there is any special character it get conflict with CommandText Syntax and generates error in inserting. I want to insert all these characters. How could i do it?
Code:
[code]....
I have the following Students class:
[Code]....
I need the 1 since it's a foreign key in another table. For the life of me, I can't get this to work like this.
I am using windows 7, my application is working fine in visual studio but when i host it and browse it through my browser getting the following error. Sometime back it worked fine but recently it started giving this error. Server Error in '/InfraICHR' Application. Compilation Error Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately. Compiler Error Message: BC2000: compiler initialization
[Code]...
I am working with a sql server database with about 50 stored procedures. The database and stored procedureswere not created by me. The stored procedures all begin with a number in their name.
Example: 17P_Comsetter
The problem I am having is that if I try and execute the stored procedure at the command line in Query Analyzer,the query analyzer appears not to like that the stored procedure begins with a number. For example:
If I try an run the stored procedure as follows:
EXEC 17P_Comsetter
Then I get the following error message:
Msg 102, ..... Incorrect Syntax near '17'
I am using SQL server 2005. Does anyone know why I am getting this error message?
I have a list view control. Each row within it has a rowid and a textbox where a note(user enters relevant info to that particular record) is entered. On a paging event I store the rowID and the note text in a generic list for retrieval if the user pages back later on. Goal here is to keep the text the user has entered. (see the code below)This generic list does in fact get populated correctly when I go to the next page currently. I can see this in Visual Studio. So now, when the user goes back to the first page I want to run a test within my Listviews ItemDataBound event. I want to see if the row ID being tested is part of the generic list. If so, I then want to take the corresponding note that is also within the list and bind it to the text box. However, I don't know how to write the correct conditional for this and how to bind the textbox if the conditional evaluates to true.
View 1 RepliesI have two generic list with Hotel class object. Both List contains hotel ID. I want to retrieve common hotel id from both Hotel List and assign to new HotelList.I have done following code for that but any other sort way to implement this kind of functionality.
[Code]....
Note: I dont want to use Linq because I am working on framwork 2.0
I'm trying to render out some images on an aspx page. Error I'm getting in the code below is:
DataBinding: '_Default+ImageThing' does not contain a property with the name 'FileName'.
public class ImageThing
{
public string FileName;
}
private void DisplayThumbnailImages()
{
ImageThing imageThing1 = new ImageThing();
ImageThing imageThing2 = new ImageThing();
imageThing1.FileName = "asdf.jpg";
imageThing2.FileName = "aaa.jpg";
List<ImageThing> imagesToRender = new List<ImageThing>();
imagesToRender.Add(imageThing1);
imagesToRender.Add(imageThing2);
Repeater1.DataSource = imagesToRender;
Repeater1.DataBind();
}
here is the aspx:
<asp:Repeater ID="Repeater1" runat="server">
<ItemTemplate>
<%#DataBinder.Eval(Container.DataItem, "FileName")%>
</ItemTemplate>
</asp:Repeater>
in my model there is a List.
public class InvoiceModel{
public int InvoiceID { get; set; }
public int Date { get; set; }[code]...
for create view i can use Html.TextBoxFor(m => m.InvoiceID) and for Date.but how can i fill List?and how can i use global for this list as Shopping cart?
Can any one can describe the main diffrence between the array and generic list.
View 6 RepliesI have one Hotel class that contains many properties. When I retrieve all hotels data from database, I store them in Generic List object.Now what I want that I have two properties called LowestPrice and HiestPrice. I want to get Minimum(LowestPrice) and Maximum(HiestPrice) from generic list directly.
Something like HotelList.Min();
Right now I have following logic implemented in my project, but I dont want to use foreach loop.
[Code]....
I have a list of Categories which I need to bind to a TreeView control in WPF and I can't find a working tutorial or get it working.My Category class consist of (ID, Title, ParentID). If the Category is a top level category the parentID is null.Can anyone sow me how to bind this to a treeview?
View 3 RepliesI have declared a simple class
[Code]....
And Pass some values to it :
[Code]....
Then I use Linq to select rows :
[Code]....
How I can enumerate it?! I used this, but it has error
[Code]....
I am using datalist to bind the generic list. On databind() command I am getting error "nable to evaluate expression because the code is optimized or a native frame is on top of the call stack.
View 3 RepliesI am trying to bind generic list to DropDownList an i am not sure how to continue.
[Code]....
I am working in asp.net 3.5 page, where I want to bind a textbox with generic list data. And I have Previous & next button. Which will show the record in textbox.
I don't want to go in db again and again.
i have these values in my generic list:
Product Name ItemCount Additional Info
Brioche & Jam 2
Almond Croissant 4
Mixed Salad(v) 20 No Onions
Mixed Salad(v) 5
What i am trying to do is group the duplicates so now the list would look like this:
Product Name ItemCount Additional Info
Brioche & Jam 2
Almond Croissant 4
Mixed Salad(v) 25 No onions
I have a GenericList and i want to convert that to DataTable My code is here
[Code]....
I am getting Count in "objFinOpRegs". But i want to convert "objFinOpRegs " to DataTable.
I have a class Trans with various properties, including a boolean named Deleted.I have a generic list of Trans that are loaded from the database. I want to use linq to set all the Trans in this list to Deleted. Can I use linq to do this?
[Code]....
Here is what is in my code-behind:
List<Event> events = new List<Event>();
protected void Page_Load(object sender, EventArgs e)
{
}
protected void AddEvent_Click(object sender, EventArgs e)
{
Event ev = new Event();
ev.Name = txtName.Text;
events.Add(ev);
}
I want to add an item to the list every time the Add button is clicked, but the list is reset after every postback. How can I keep the data in the list between postbacks?
<%@ Page Language="javascript"%>'m writing a website that's a little heavy on the database connection calls, so I've decided to try to encapsulate it in a Javascript pseudo-class. When I try to instantiate the MySqlDataAdapter, I get the error "Format of the initialization string does not conform to specification starting at index 0." While I can appreciate this, I've used the same connection string (more or less) across many pages now, without issue when I'm not trying to use this class.I'm a little confused - does anyone have any idea why line would be throwing this error?
test.aspx
[Code]....