brgdotnet
asked on
Checkbox in a dynamic GridVIew is not clickable?
I have created a GridView control which I populate dynamically in C#. Everything works great, except that the check boxes in my GridView control are not clickable. They appear to be greyed out. Do any experts know why this is happening (meaning Check box not clickable)? Below is my code with my data table also scripted out.
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Crackle.aspx.c s" Inherits="WebApplication1. Crackle" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<asp:GridView ID="GridView1" runat="server"></asp:GridV iew>
<div>
</div>
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:Customer sConnectio nString2 %>" SelectCommand="SELECT [Id], [Name], [TrueOrFalse] FROM [SampleData]"></asp:SqlDat aSource>
</form>
</body>
</html>
public partial class Crackle : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
GridView1.DataSource = SqlDataSource1;
GridView1.DataBind();
}
}
USE [Customers]
GO
/****** Object: Table [dbo].[SampleData] Script Date: 1/19/2017 11:42:45 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[SampleData](
[Id] [int] NULL,
[Name] [nvarchar](50) NULL,
[TrueOrFalse] [bit] NULL
) ON [PRIMARY]
GO
INSERT [dbo].[SampleData] ([Id], [Name], [TrueOrFalse]) VALUES (1, N'Jed', 0)
GO
INSERT [dbo].[SampleData] ([Id], [Name], [TrueOrFalse]) VALUES (3, N'Marciasi', 0)
GO
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Crackle.aspx.c
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<asp:GridView ID="GridView1" runat="server"></asp:GridV
<div>
</div>
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:Customer
</form>
</body>
</html>
public partial class Crackle : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
GridView1.DataSource = SqlDataSource1;
GridView1.DataBind();
}
}
USE [Customers]
GO
/****** Object: Table [dbo].[SampleData] Script Date: 1/19/2017 11:42:45 PM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[SampleData](
[Id] [int] NULL,
[Name] [nvarchar](50) NULL,
[TrueOrFalse] [bit] NULL
) ON [PRIMARY]
GO
INSERT [dbo].[SampleData] ([Id], [Name], [TrueOrFalse]) VALUES (1, N'Jed', 0)
GO
INSERT [dbo].[SampleData] ([Id], [Name], [TrueOrFalse]) VALUES (3, N'Marciasi', 0)
GO
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Actually I ended up doing it in the C# in the Row Data Bound event handler.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER