I have a databound dropdownlist on my asp.net page.
<asp:DropDownList ID="ddlCases" runat="server"></asp:DropDownList>
I am populating ddlCases as
ddlCases.DataSourse = SelectItems();
ddlCases.DataValueField = "itemid";
ddlCases.DataTextField = "itemname";
ddlCases.SelectedIndex = 0;
ddlCases.DataBind();
SelectItems() return a datatable.
What I want to do is to concatenate each item with a sequence number(1,2,3..) in which sequence they appear in the dropdownlist something like
1. itemname1
2. itemname2
3. itemname3
What are my options for achieving this??
Regards,
ZB
You can do it with linq, something like this should work
EDIT
Select method creates another
IEnumerable(collection) that contains new anonymous type,where index property is index in the first array, itemid is itemid and itemname index + itenmaneSo shortly with LINQ statments we create another temporary class, that contains properties we want
Hope this make sense
EDIT
If SelectItems method returns untyped data table, as @VinayC suggested in the comment you should write