To Find Control in ItemCommand Event of ListView is little simple than finding in gridview but finding a DataKeys from ListView are not simple as find control :
1. To Find a Control From ListView is as follows
Label LabelEmail = (Label)e.Item.FindControl("LabelEmail");
And Now You Can Access that Properties of that Control.
LabelResult.Text = LabelEmail.Text;
2. For Finding a DataKeys the following way is used First Create a ListViewDataItem object.
For Eg:
ListViewDataItem dataItem = (ListViewDataItem)e.Item;
3. Finally You Can get datakeys of that ListView using that dataitem DisplayIndex.
For Eg:
string code = ListView1.DataKeys[dataItem.DisplayIndex].Values[0].ToString();
No comments:
Post a Comment