Question GridView CheckBox Enable & Checked

skaswani

Member
Joined
Oct 5, 2008
Messages
20
Programming Experience
Beginner
Dear All,

Greetings


I am using VS 2010 , VB.net, with SQL Server 2008 & Windows 7

I have a datagrid name as gvBusinessNature2

I want to Checked a CheckBox as well as show as disabled where a bound field is not ?NA?

Can you pls help me

Thanks



VB.NET:
<asp:GridView ID="gvBusinessNature2" runat="server" AllowPaging="True" 
                                AllowSorting="True" AutoGenerateColumns="False" BackColor="White" 
                                OnSorting ="gvBusinessNature2_Sorting" 
                                OnPageIndexChanging="gvBusinessNature2_PageIndexChanging"
                                BorderColor="#3366CC" BorderStyle="None" BorderWidth="1px" CellPadding="4">
                                <Columns>
                                    <asp:TemplateField HeaderText="P">
                                        <EditItemTemplate>
                                            <asp:CheckBox ID="CheckBox1" runat="server" />
                                        </EditItemTemplate>
                                        <ItemTemplate>
                                            <asp:CheckBox ID="CheckBox1" Checked="false" runat="server" />
                                        </ItemTemplate>
                                    </asp:TemplateField>
                                    <asp:TemplateField HeaderText="S">
                                        <EditItemTemplate>
                                            <asp:CheckBox ID="CheckBox2" runat="server" />
                                        </EditItemTemplate>
                                        <ItemTemplate>
                                            <asp:CheckBox ID="CheckBox2" Checked="false"                                             runat="server" />
                                        </ItemTemplate>
                                    </asp:TemplateField>
                                    <asp:BoundField DataField="ID" HeaderText="ID" SortExpression="ID" >
                                    <ItemStyle Width="50px" />
                                    </asp:BoundField>
                                    <asp:BoundField DataField="BusinessNature" HeaderText="Business Nature" 
                                        SortExpression="BusinessNature" >
                                    <ItemStyle Width="300px" />
                                    </asp:BoundField>
                                    <asp:BoundField DataField="Description" HeaderText="Description" 
                                        SortExpression="Description" >
                                    <ItemStyle Width="300px" />
                                    </asp:BoundField>
                                    <asp:BoundField DataField="Action" HeaderText="Action" 
                                        SortExpression="Action" />
                                    <asp:TemplateField HeaderText="Details View">
                                    <ItemTemplate>
                                        <div>
                                            <a runat='server'
                                            onclick='<%# String.Format("ShowDetails(""{0}"");", Eval("Details")) %>'
                                            style='text-decoration:underline;'>Details</a>
                                        </div>
                                    </ItemTemplate> 
                                    </asp:TemplateField>
                                    <asp:BoundField Visible="False" DataField="LogID" HeaderText="LogID" />
                                    <asp:BoundField DataField="ApprovedBy_A" HeaderText="ApprovalA" 
                                        NullDisplayText="NA" />
                                    <asp:BoundField DataField="ApprovedBy_B" HeaderText="ApprovalB" 
                                        Visible="False" NullDisplayText="NA" />
                                </Columns>
                                <FooterStyle BackColor="#99CCCC" ForeColor="#003399" />
                                <HeaderStyle BackColor="#003399" Font-Bold="True" ForeColor="#CCCCFF" />
                                <PagerStyle BackColor="#99CCCC" ForeColor="#003399" HorizontalAlign="Left" />
                                <RowStyle BackColor="White" ForeColor="#003399" />
                                <SelectedRowStyle BackColor="#009999" Font-Bold="True" ForeColor="#CCFF99" />
                                <SortedAscendingCellStyle BackColor="#EDF6F6" />
                                <SortedAscendingHeaderStyle BackColor="#0D4AC4" />
                                <SortedDescendingCellStyle BackColor="#D6DFDF" />
                                <SortedDescendingHeaderStyle BackColor="#002876" />
                            </asp:GridView>
 
Back
Top