开发者

-Get the selected row item from Datalist-

may I know how to get the selected item in datalist? For eg, I'm displaying a list of food items in a datalist with food name, price, type, a button(Click to order). Now I wanted to click on the selected button and get that specific food name, pri开发者_如何学Pythonce & etc from the datalist. Thanks!


Use the ItemCommand event,
take a look at this tutorial: Custom Buttons in the DataList and Repeater


protected void DataList1_ItemCommand(object source, DataListCommandEventArgs e)
{
   DataList1.SelectedIndex = e.Item.ItemIndex;
   Label1.Text = ((ImageButton)DataList1.SelectedItem.FindControl("ImageButton1")).ImageUrl.ToString();

}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜