Hi Yankee,
You should be able to check a property during the list's DataBound event and
then disable an item based on the value.
Here's the idea:
protected void RadioButtonList1_DataBound(object sender, EventArgs e)
{
foreach (ListItem li in RadioButtonList1.Items)
{
li.Enabled = (bool)(li.Value.Contains(".ca"));
}
}
Full code below.
Ken
using System;
using System.Collections.Generic;
using System.Web;
/// <summary>
/// Summary description for datacollection
/// </summary>
public class datacollection
{
public List<string> GetDataCollection()
{
List<string> sites = new List<string>();
sites.Add("
www.kencox.ca");
sites.Add("
www.microsoft.com");
sites.Add("
www.asp.net");
return sites;
}
}
<%@ Page Language="C#" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"
http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
protected void RadioButtonList1_DataBound(object sender, EventArgs e)
{
foreach (ListItem li in RadioButtonList1.Items)
{
li.Enabled = (bool)(li.Value.Contains(".ca"));
}
}
</script>
<html xmlns="
http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:RadioButtonList ID="RadioButtonList1" runat="server"
DataSourceID="ObjectDataSource1"
OnDataBound="RadioButtonList1_DataBound">
</asp:RadioButtonList>
</div>
<asp:ObjectDataSource ID="ObjectDataSource1" runat="server"
SelectMethod="GetDataCollection"
TypeName="datacollection"></asp:ObjectDataSource>
</form>
</body>
</html>