GridView CheckBox Enable & Checked
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3

Thread: GridView CheckBox Enable & Checked

Hybrid View

  1. #1
    Join Date
    Apr 2008
    Posts
    3

    Question GridView CheckBox Enable & Checked

    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, i want to use vb.net code

    Thanks


    PHP Code:
    <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
    Last edited by GremlinSA; December 2nd, 2013 at 06:16 AM. Reason: added code tags

  2. #2
    Join Date
    Jun 2005
    Location
    JHB South Africa
    Posts
    3,772

    Re: GridView CheckBox Enable & Checked

    [Moved Thread]
    Articles VB6 : Break the 2G limit - Animation 1, 2 VB.NET : 2005/8 : Moving Images , Animation 1 , 2 , 3 , User Controls
    WPF Articles : 3D Animation 1 , 2 , 3
    Code snips: VB6 Hex Edit, IP Chat, Copy Prot., Crop, Zoom : .NET IP Chat (V4), Adv. ContextMenus, click Hotspot, Scroll Controls
    Find me in ASP.NET., VB6., VB.NET , Writing Articles, My Genealogy, Forum
    All VS.NET: posts refer to VS.NET 2008 (Pro) unless otherwise stated.

  3. #3
    Join Date
    Jun 2005
    Location
    JHB South Africa
    Posts
    3,772

    Re: GridView CheckBox Enable & Checked

    There are several ways to do this...

    One is in the VB code using the Databound event...
    Code:
        Protected Sub GridView1_RowDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles GridView1.RowDataBound
            If e.Row.RowType = DataControlRowType.DataRow Then
    
            End If
        End Sub
    Another would be to include late binding into the ASP code...
    PHP Code:
     <asp:CheckBox ID="CheckBox2" Checked="<%BoundData.value%>" Enabled="<%BoundData.value2%>" runat="server" /> 
    Articles VB6 : Break the 2G limit - Animation 1, 2 VB.NET : 2005/8 : Moving Images , Animation 1 , 2 , 3 , User Controls
    WPF Articles : 3D Animation 1 , 2 , 3
    Code snips: VB6 Hex Edit, IP Chat, Copy Prot., Crop, Zoom : .NET IP Chat (V4), Adv. ContextMenus, click Hotspot, Scroll Controls
    Find me in ASP.NET., VB6., VB.NET , Writing Articles, My Genealogy, Forum
    All VS.NET: posts refer to VS.NET 2008 (Pro) unless otherwise stated.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center