1

I have a arraylist of employees from the gridview in my ASP.net Page as shown below:

ArrayList tempempList = new ArrayList();
        List<Employee> emps = new List<Employee>();
        for (int i = 0; i < gvemp.Rows.Count; i++)
        {
            if (((CheckBox)gvemp.Rows[i].FindControl("cbAssign")).Checked)
            {
                tempempList.Add(((Label)gvemp.Rows[i].FindControl("lblempSeqNo")).Text);
            }
        }

Now I have List and Employee object consists of the following properties empID, empName,empAge,empSalary

Now for each empID from tempempList I need to populate the List

I am not sure how I can populate emps.

Appreciate your help

1 Answer 1

1

The List<T> object is just the strongly-typed version (generic) of ArrayList. ArrayList is preserved for traditional purposes, and List<T> should be utilized when necessary.

You can call the List<T>.Add() method, just like you did for the ArrayList.Add() method. So something like:

emps.Add(yourValue);

That should suffice.

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks. But where do I populate each employee object?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.