Link to home
Start Free TrialLog in
Avatar of kimmie8000
kimmie8000Flag for United States of America

asked on

I would like a gridview to show a checkbox as true if there is data in a field

Can someone show me the code to making an ASPX.NET feild to be set to true open loading the data in C#.  I need to check for a feild to be populated then set this to true.  It keeps showing my template field in error.
if (License1 != string.Empty || License1 != null)
        {
           // I change the Item gridview name...
            CBAddLA1.Checked = true;



        }
        else
        {
            CBAddLA1.Checked = false;
        }

When I load the grid I would like to change the check mark to true if there is data in the field.  Otherwise, I want it to be false.  There seems to be no way to grab turn the checkbox on or off before binding the grid.

 <asp:TemplateField HeaderText="Advanced Clinical">
                    <EditItemTemplate>
                        <asp:CheckBox ID="CBAddLA1" runat="server" text='<%# Bind("LicenseAssociation1Default") %>' />
                    </EditItemTemplate>
                    <ItemTemplate>
                        <asp:CheckBox ID="CBAddLA1" runat="server" 
                            Enabled="false" />
                    </ItemTemplate>
                    <ControlStyle CssClass="standard-text" Width="100px" />
                    <FooterStyle CssClass="standard-text" />
                    <HeaderStyle BackColor="#996633" CssClass="standard-text" ForeColor="White" 
                        HorizontalAlign="Left" />
                    <ItemStyle CssClass="standard-text" />
                </asp:TemplateField>

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Carl Tawn
Carl Tawn
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial