开发者

ASP.NET Repeater Selection

开发者 https://www.devze.com 2023-01-22 05:13 出处:网络
I have a se开发者_StackOverflowlect button(LinkButton)insidetheRepeater.Wheniselect thebutton thatrow should be appearinListViewcontrol.ButRepeatercontroldoes notsupport DataKey,then how can iachievet

I have a se开发者_StackOverflowlect button(LinkButton) inside the Repeater.When i select the button that row should be appear in ListView control.But Repeater control does not support DataKey,then how can i achieve this?


You can have hidden field inside repeater and achieve your task as follows:

protected void SelectLink_Click(object sender, EventArgs e)    
{
    RepeaterItem item = (sender as LinkButton).Parent as RepeaterItem;
    HiddenField hdnId = item.FindControl("hdnId") as HiddenField;
    string id = hdnId.Value.ToString();// incase  your id  is  string     
    //..... 
}


What you are looking for is the ItemCommand event of Repeater. It is a kind of key.

0

精彩评论

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