ListView_ItemDataBound event can used to modify the controls inside the ListView in codebehind.The below code is to disable html input radio buttons inside a listview.
protected void MyListView_ItemDataBound(object sender, ListViewItemEventArgs e)
{
ListViewDataItem dataItem = (ListViewDataItem)e.Item;
if (e.Item.ItemType == ListViewItemType.DataItem)
{
HtmlInputRadioButton oRadioButton = (HtmlInputRadioButton)dataItem.FindControl("MyRadioButton");
if (oRadioButton != null && MyConditionEqualsTrue) //Based on certain condition
oRadioButton.Attributes["disabled"] = "disabled";
}
}
protected void MyListView_ItemDataBound(object sender, ListViewItemEventArgs e)
{
ListViewDataItem dataItem = (ListViewDataItem)e.Item;
if (e.Item.ItemType == ListViewItemType.DataItem)
{
HtmlInputRadioButton oRadioButton = (HtmlInputRadioButton)dataItem.FindControl("MyRadioButton");
if (oRadioButton != null && MyConditionEqualsTrue) //Based on certain condition
oRadioButton.Attributes["disabled"] = "disabled";
}
}
No comments:
Post a Comment