开发者

-Get the selected row item from Datalist-

开发者 https://www.devze.com 2022-12-20 10:55 出处:网络
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 sele

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

精彩评论

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