Web Forms :: Unable To Add List Obj Into Arraylist
Feb 12, 2010
I am trying to retrieve a arraylist frm a session and add in more objects into the arraylist on top of the existing object in the arraylist.But i have encounter problem at the foreach loop where it promted me a error message shown below
Object reference not set to an instance of an object.
below are the sample code.
public void addItemToArraylist(List<LibraryItem> temp) //l temp pass in 5 items each tim
{
ArrayList storeItems = new ArrayList();
storeItems = (ArrayList)Session["storeItems"];
foreach (LibraryItem items in temp)
I am working in asp.net 3.5 with c# and sqlserver 2005 as database. I my project i have to select some of the checkbox of a gridview and update the database according to that. I want to store all the selected box in a arraylist and update the database according to the selected list . But i am not getting how to proceed.
i want to create a arraylist which will able to store user info like (username,machineIP,port ) for each user in the list & retrive this data when needed . any one tell me how i can do it or any alternative way without database or xml file.
i m new to asp.net 3.5 linq and dnt worked much on generics.i m using IEnumerable to return set of results.i m binding this IEnumerable type method directly to datagrid source then it works fine.But i dnt knw how to iterate through this collection??Same way i m using List<String> to return columns like this
I have a drop down list that is populated with customer IDs. When I write to the db a value of 11 is written for the customer ID 13 when it is chosen from the drop down . I thought this was because I was using the SelectedIndex and how it is 0 based like an array. In the drop down list I choose 13. Id 2 is missing from the drop down list because that record was deleted. I thought these two things together explained the two digit discrepancy with the what i got when I used the Selected Index property. I then decided to use the SelectedValue property which should give me 13 when I choose 13 in the drop down list.
The same thing happens when I use the SelectedValue property. I used the SelectedValue property and chose 13 in the drop down list. This also gave me 11 as the value that was written to the db. This makes no sense to me. If I chose 13 in the drop down then 13 should have been written to the db when using the SelectedValue.
I'm using a Sql Data Source temporarily to populate this with the CustID.
I am using asp.net 3.5. I filled dropdown list in javascript using ajax service but unable to get its selected value in button click event on server side.
I am having trouble populating a database that is shown in a list box. The user uses a text box to enter an ID and the ID will bring up information. The problem I am having is in the highlighted area. It says The expression contains an invalid string constant: '1010. where 1010 is what i entered in the text box to test it.
I'm trying to define the parameters of my data source using a stored procedure. My Stored Procedure Syntax is perfect and i'm happy with that, i've just got trouble with connecting my parameters to my controls. I have 19 Parameters, of which i've managed to connect 17 to controls within my ASP.Net form (some to text boxes, some to ddls etc...)
However, i'm trying to connect a particular parameter to a control, but when i drop down my list of controls it's not visible? The control is within a hidden panel so i've un-hidden it and it's still not there. I've even commented out the panel and tried that but i can't find this control! I just cant seem to get this control to appear in the list.
Has any one seen anything like this before at all?
I have a function and I am getting an error message. I need to convert my DataTable to an array and be able to access each line individually. This is the error message: Operator '-' is not defined for types 'System.Data.DataRowCollection' and 'Integer'.
I have a procedure that is used to look up user permissions in our custom table, There is 1 record for each user and about 20 columns for each of the permissions.
How can i take the column values and place into an array?
All the column are bit type and 1 is int. Is it possible to take the values returned and add to an ArrayList?
And then once the values are in the array, how to loop thru it and go to certain index to check the value.
I am working on a VS 2005 based Environment, on .NET 2.0.am trying to Bind a ArrayList to a GridView. The ArrayList consists of Objects of a Specific Class. When i bind it now all the Properties in the class. The catch is I do not want to display all these properties on the GridView.For Example: The objects of this class is held in ArrayList, when i Bind it to GridView it shows all the four Columns, Where as i want to show only 2...
How do you go about removing multiple items from a array list?
I'm using the RemoveAt() method to remove but doing that resets the ArrayList's index which cause me problems if the user selects to remove 1 & 3 out of a 3 list array since once it removes 0 the array list now just has 0 & 1.
i want to show the arrayliust items in the listbox, for that i had stored some data in array list, and now i want that if i gv any id which is in the array list its corresponding details are displayed in listbox. I had two fields ID, Name, and when i give id its corresponding name should be shown in list box.
I have a GridView control of 5 columns out of which 2 are actually computed (there cell values comes from column 1, 2 and 3) columns. I want to save all the values of my gridview columns in a 5 dimension ArrayList and then lateron bind that ArrayList with a repeator control.
I am doing a leave application in which I want to display working days (dates) apart from holidays and weekends. So first I make sure that it is not a holiday by comparing with my holidaymaster table and not saturday or sunday. My code so far looks like this...
//Check whether it is a holiday(compare with holiday_master) or saturday or sunday for (DateTime i = LeaveStartDate; i <= LeaveEndDate; i = i.AddDays(1))
openDB() Dim inList As String Dim getCourses For k As Integer = 0 To arLcID.Count - 1 If k > 0 Then inList &= "," End If inList = arLcID(k).ToString getCourses = "select cID,cCode,cUnit from [university].[Courses_1] where cID ='" & inList & "'" insertCMD = New Data.SqlClient.SqlCommand
[Code] ....
This code is not returning any value, when the arraylist is removed it returns value.
I've been trying to bound an arraylist to a grdview for display and managed to work out the following:
[Code]....
At the point where rows are added to dt, i'm trying to get arraylist (Tweet) to be read row by row to insert each of it's fields into dt. There is no error but when run in browser, each cell of the gridview shows 'DataExtraction.Tweet'.I'm not sure where to go from here.
I have an arraylist that contains some values. (e.g. playerName). I also queried for values in the database (e.g. playerName, playerSales) and I need to match the playerName in the arraylist to the corresponding ones that I did a query from the database. (match those with the same playerName). From there, I need to create a bar graph with the respective playerName and their sales (playerSales).
A portion of the code is shown below:
[Code]....
The arraylist I mentioned was saved to a session to be used in another page. Is my code right? And how can I create the graph from the values?