>>>>>>>>><asp:GridView ID="GridView1" >>>>>>>>> runat="server" >>>>>>>>> AutoGenerateColumns="False"> >>>>>>>>> >>>>>>>>> <Columns> >>>>>>>>> >>>>>>>>> <asp:BoundField DataField="RightKey" HeaderText="RightKey" /> >>>>>>>>> >>>>>>>>> <asp:TemplateField HeaderText="Allow / Deny"> >>>>>>>>> <ItemTemplate> >>>>>>>>> <asp:DropDownList DataSource='<# GetAllowDenyValues() >' DataTextField="AllowDeny" >>>>>>>>> DataValueField="AllowDeny" ID="AllowDeny" runat="server"></asp:DropDownList> >>>>>>>>> </ItemTemplate> >>>>>>>>> </asp:TemplateField> >>>>>>>>> >>>>>>>>> <asp:BoundField DataField="RightName" HeaderText="Right Name" /> >>>>>>>>> >>>>>>>>> </Columns> >>>>>>>>> >>>>>>>>></asp:GridView> >>>>>>>>>>>>>>>>>>
>>>>>>>>>private string ConnectionString = string.Empty; >>>>>>>>> >>>>>>>>>protected void Page_Load(object sender, EventArgs e) >>>>>>>>>{ >>>>>>>>> if (!IsPostBack) >>>>>>>>> { >>>>>>>>> ConnectionString = ConfigurationManager.ConnectionStrings["MyConnStr"].ConnectionString; >>>>>>>>> BindData(); >>>>>>>>> } >>>>>>>>>} >>>>>>>>> >>>>>>>>>public DataSet GetAllowDenyValues() >>>>>>>>>{ >>>>>>>>> SqlConnection myConnection = new SqlConnection(ConnectionString); >>>>>>>>> SqlDataAdapter ad = new SqlDataAdapter("SELECT DISTINCT CASE WHEN AllowDeny = 0 " + >>>>>>>>> " THEN 'No' WHEN AllowDeny = 1 THEN 'Yes'END AS AllowDeny FROM sec_Rights ", myConnection); >>>>>>>>> DataSet ds = new DataSet(); >>>>>>>>> ad.Fill(ds, "AllowDeny"); >>>>>>>>> return ds; >>>>>>>>>} >>>>>>>>> >>>>>>>>>private void BindData() >>>>>>>>>{ >>>>>>>>> SqlConnection conn = new SqlConnection(ConnectionString); >>>>>>>>> SqlParameter pUserKey = new SqlParameter("@UserKey", 2); >>>>>>>>> SqlCommand cmd = new SqlCommand(); >>>>>>>>> cmd.Parameters.Add(pUserKey); >>>>>>>>> cmd.Connection = conn; >>>>>>>>> cmd.CommandText = "as_GetRightsForUserEx"; >>>>>>>>> cmd.CommandType = CommandType.StoredProcedure; >>>>>>>>> >>>>>>>>> SqlDataAdapter ad = new SqlDataAdapter(); >>>>>>>>> ad.SelectCommand = cmd; >>>>>>>>> DataSet ds = new DataSet(); >>>>>>>>> ad.Fill(ds, "Rights"); >>>>>>>>> GridView1.DataSource = ds; >>>>>>>>> GridView1.DataBind(); >>>>>>>>>} >>>>>>>>> >>>>>>>>>>>>>>>>>>
<asp:TemplateField HeaderText="Allow / Deny"> >>>>>> <ItemTemplate> >>>>>> <asp:DropDownList Id="AllowDeny" runat="server" >>>>>> SelectedValue='< %# Bind("AllowDeny") % >' > >>>>>> <asp:ListItem Value="1">Yes</asp:ListItem> >>>>>> <asp:ListItem Value="0">No</asp:ListItem> >>>>>> </asp:DropDownList> >>>>>> </ItemTemplate> >>>>>></asp:TemplateField>>>>>>
><asp:TemplateField HeaderText="Allow / Deny"> > <ItemTemplate> > <asp:CheckBox > ID="chkStatus" > runat="server" > Checked='< %# Convert.ToBoolean(Eval("AllowDeny")) % >' > Text='< %# Eval("AllowDeny").ToString().Equals("1") ? " Allow " : " Deny " % >' /> > </ItemTemplate> ></asp:TemplateField> >FWIW I think a hybrid solution would be most intuitive : Use a ComboBox but with Allow'/Deny as the options rather than Yes/No. Having the checkbox flip meaning depending on the current setting could be a bit confusing......