Click here to Skip to main content
15,912,400 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
Gridview as follows


Room Course Room Course Room Course Room Course

11 Button 21 Button 31 Button 41 Button
12 Button 22 Button 32 Button 42 Button
13 Button 23 Button 33 Button
14 Button 24 Button 34 Button



in gridview how to add button for each row.


i want to add button for each room. for that above gridview how can i do using c#.


Rgds,
Narasiman P.
Posted

XML
<asp:GridView ID="GridView1" runat="server"
              DataSourceID="SqlDataSource1"
              AutoGenerateColumns="false"
              CellPadding="2" ForeColor="#333333"
              GridLines="Both"
              DataKeyNames="ID"
              OnRowDataBound="GridView1_RowDataBound">
<Columns>
<asp:TemplateField>

<ItemTemplate>
<asp:Label ID="lblField" runat="server" Text='<%#Eval("Your Field") %>'></asp:Label>
 <asp:Button ID="btnSubmit" runat="server" Text="Submit" />

</ItemTemplate>
</asp:TemplateField>

</Columns>
</asp:GridView>


I created a single Label field to hold your value and a button next by the label, you can increase the number of controls depend upon your requirement.

also see the link it may helps
http://msdn.microsoft.com/en-us/library/bb288032.aspx[^]


Hope it helps
 
Share this answer
 
XML
<ItemTemplate>
           <td align="center">
               <CC:SelectLink CssClass="selectbutton" runat="server"/><br />
               <asp:LinkButton runat="server" ID="Review"
                   CommandName="Select" CommandArgument="Review" Text="Review" CssClass="selectbutton btn-custom"/>
               <CC:AlphaLabel ID="ID"    runat="server" Visible="false" Text='<%#Eval("DBValue") %>' />
           </td>
 
Share this answer
 
XML
<asp:GridView AutoGenerateColumns="false" runat="server">
        <Columns>
            <asp:BoundField DataField="ColumnName1" />
            <asp:BoundField DataField="ColumnName2" />
            <asp:BoundField DataField="ColumnName3" />
            <asp:TemplateField>
                <ItemTemplate>
                    <asp:Button ID="SanctionedButton" Text="Sanctioned" runat="server" />
                    <asp:Button ID="DeclineButton" Text="Decline" runat="server" />
                </ItemTemplate>
            </asp:TemplateField>
        </Columns>
    </asp:GridView>



http://forums.asp.net/t/1726832.aspx/1[^]
 
Share this answer
 
Comments
Member 10554512 14-Feb-14 5:23am    
How will I know that
of which row the Button_Click event is fired,
can i know the index no.. or can i pass id ??
Member 13577557 20-Dec-17 0:42am    
how to Program buttons in a gridview and their querys

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900