access to datalist value

You can access the Datalist values of a row like this :

In the ItemDataBound event of the DataList,
if(e.Item.ItemType == ListItemType.Item || e.Item.ItemType ==
ListItemType.AlternatingItem){
object row_items=e.Item.DataItem;
// If you have a column called customerId,
object items = e.Item.DataItem;
string str1=Convert.ToString(DataBinder.Eval(row_items,”c ustomerId”));
}

Additional info:
You can find the controls in thge ItemTemplate of your datalist :
In ItemDataBound event :
eg :

((LinkButton)e.Item.FindControl(“LinkB”)).CommandA rgument=e.Item.ItemIndex.T
oString();

This will set the commandargument for the Linkbutton, LinkB.
The above code is in C#.
You can easily convert it into VB.NET.Let me know if you have any
problems.

Marshal Antony

Deixe um comentário

O seu endereço de email não será publicado. Campos obrigatórios marcados com *