return a record from array list [Resolved]

Posted by Jopito under ASP.NET on 1/7/2014 | Points: 10 | Views : 579 | Status : [Member] | Replies : 4
Hellow pals,i have a method which returns a array list .Is it possible to pick one record in the returned data and bind the datafields to textboxes?Thanks

Mark as answer if satisfied


Responses

Posted by: vishalneeraj-24503 on: 1/7/2014 [Member] [MVP] Platinum | Points: 50

Up
0
Down

Resolved
Check:-

ArrayList obj_name = new ArrayList();
obj_name.Add("vishal");
obj_name.Add("kumar");

string str = Convert.ToString(obj_name[0]); //0 index means vishal
string st = str;


Jopito, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: kgovindarao523-21772 on: 1/7/2014 [Member] [MVP] Bronze | Points: 25

Up
0
Down
Yes,
It is possible to pick one record.
Example:
public ArrayList get()

{
ArrayList list = new ArrayList();
list.Add("dotnet");
list.Add("funda");

return list;
}


in Page_load(or in your function)

ArrayList oArrayList = get();
srting a = (string) oArrayList.ToArray().First(x => x.Equals("dotnet')) ;// your query after ToArray() and type casting required



Thank you,
Govind

Jopito, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Jopito on: 1/7/2014 [Member] Starter | Points: 25

Up
0
Down
I have used it but gives error cannot convert to long.Can you please tell me how to use the first item indexer of returned object from the list

Mark as answer if satisfied

Jopito, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: kgovindarao523-21772 on: 1/7/2014 [Member] [MVP] Bronze | Points: 25

Up
0
Down
Hi,

In the last Post, I specify that type casting is required.
If your array list takes long
specify (long) at right side of the '='

Thank you,
Govind

Jopito, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response