0

I need to add column with button in GridView ? i tied with asp:button i got error also i tried asp:ButtonField i got this error:

"Error Creating Control - narudzbaGridType 'System.Web.UI.WebControls.ButtonField' does not have a public property named 'ID'.

but i gave ID name to my Button field asp:ButtonField ID="example"

<asp:GridView ID="narudzbaGrid" runat="server" AutoGenerateColumns="false">
        <Columns>
            <asp:BoundField DataField="Let" HeaderText="Let"/>
            <%--<asp:BoundField DataField="Kolicina" HeaderText="Kolicina"/>--%>
        </Columns>
</asp:GridView>
1
  • It's an error because ButtonField doesn't have an ID property. Commented Sep 22, 2014 at 19:39

2 Answers 2

1

You can use TemplateField like this (add to columns block):

<asp:templatefield headertext="Author Name">
    <itemtemplate>
      <asp:button id="buttonl"
        Text= 'Click Me'
        runat="server"/> 
    </itemtemplate>
  </asp:templatefield>
Sign up to request clarification or add additional context in comments.

Comments

1

Hi you need to add an TemplateField. Everybody like use ImageButton but if you want use other control go ahead.

<asp:TemplateField HeaderText="Edit" ItemStyle-HorizontalAlign="Center" >
  <ItemTemplate>
     <asp:ImageButton ID="imgBtnEditar" runat="server" ImageUrl="~/iconos/Image.png" CommandName="edit" ToolTip="Edit">
     </asp:ImageButton>
  </ItemTemplate>
  <ItemStyle Height="8px"></ItemStyle>                                
</asp:TemplateField>

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.