Click here to Skip to main content
16,012,468 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi i am using data list .. there i have 2 fields

1 sno
2 name


they both are label.. which is bind...


Now i have 1 button called show outside of datalist..

i want when i click on button...

all the name which is in datalist name column...
store in 1 array...

how i can do this....
Posted

1 solution

Hi,
declare one string array like
String[] Names=new String[10];

protected void DataList1_ItemDataBound(object sender, DataListItemEventArgs e)
{
    if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
    {
        Label pris = (Label)e.Item.FindControl("GiveYourLableId");
        Names.Add(pris.Text);
    }
}


This method will fire for each item in your DataList.
 
Share this answer
 
v2
Comments
RaviRanjanKr 14-Sep-11 9:52am    
Always use "pre" tag to wrap code text.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900