refer this example
<asp:RadioButtonList ID="RadioButtonList1" runat="server">
<asp:ListItem Text="one" Value="1" />
<asp:ListItem Text="two" Value="2" />
<asp:ListItem Text="three" Value="3" />
<asp:ListItem Text="four" Value="4" />
</asp:RadioButtonList>
Quote:
I may need to disable one or more of those ListItems.
string[] itemsToDisable = { "1", "2" };
foreach (string item in itemsToDisable)
{
var listItem = RadioButtonList1.Items.FindByValue(item);
if (listItem != null)
listItem.Enabled = false;
}
Note : Formatting the sql Query string is
vulnerable to
SQL Injection[
^] attacks
always use
Parameterized queries to prevent SQL Injection Attacks in SQL Server[
^]
use
FindByText[
^] or
FindByValue[
^] based on how you are populating the list items.
Correction to your code
SqlConnection cnn = new SqlConnection(ConfigurationManager.ConnectionStrings["ConnectionString"].ConnectionString);
string Query = "select slot from appoint where selectdate =@date";
SqlCommand cmd = new SqlCommand(Query, cnn);
cmd.Parameters.Add("@date", txtdate.Text);
DataTable dtAdmin = new DataTable();
SqlDataAdapter da = new SqlDataAdapter(cmd);
da.Fill(dtAdmin);
RadioButtonList1.Enabled = dtAdmin.Rows.Count > 0;