1 Replies - 8412 Views - Last Post: 08 February 2012 - 11:20 AM Rate Topic: -----

#1 Ayumi  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 17
  • Joined: 05-March 10

[Question] how to add checkbox and textbox in data grid view?

Posted 05 February 2012 - 10:50 PM

I badly need checkboxes on my grid view for the purpose of 'add to cart' in my Ecommerce site but I can't add checkboxes and textboxes..
I tried using this code:

 
<asp:GridView ID="GridView1" runat="server">

                   <Columns>

                        <asp:TemplateField >
                            <ItemTemplate>
                                <asp:CheckBox ID="myCheckBox" runat="server" />
                            </ItemTemplate>
                        </asp:TemplateField>

                  </Columns>

               </asp:GridView>

 



The checkboxes shows on the design view but when I run the whole project, the column is not there..

Is This A Good Question/Topic? 0
  • +

Replies To: [Question] how to add checkbox and textbox in data grid view?

#2 ajwsurfer  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 21
  • View blog
  • Posts: 373
  • Joined: 24-October 06

Re: [Question] how to add checkbox and textbox in data grid view?

Posted 08 February 2012 - 11:20 AM

Along with
  <asp:TemplateField>


there are also
                        <EditItemTemplate>
                        <FooterTemplate>
                        <InsertItemTemplate>
                        <HeaderTemplate>


Try placing your control in the <EditItemTemplate>
like so:
<asp:GridView ID="GridView1" runat="server">

                   <Columns>

                        <asp:TemplateField >
                            <ItemTemplate>
                                blank
                            </ItemTemplate>
                            <EditItemTemplate>
                                <asp:CheckBox ID="myCheckBox" runat="server" />
                            </EditItemTemplate>
                        </asp:TemplateField>

                  </Columns>

               </asp:GridView>


Was This Post Helpful? 0
  • +
  • -

Page 1 of 1