如何使用c#在asp.net中的每一行的gridview中添加按钮字段 [英] how to add button field in gridview for each row in asp.net using c#

查看:71
本文介绍了如何使用c#在asp.net中的每一行的gridview中添加按钮字段的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Gridview如下





房间课程房间课程房间课程房间课程



11按钮21按钮31按钮41按钮

12按钮22按钮32按钮42按钮

13按钮23按钮33按钮

14按钮24按钮34按钮







gridview如何为每行添加按钮。 />




i想为每个房间添加按钮。对于gridview上面的我如何使用c#。





Rgds,

Narasiman P.

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.

推荐答案

<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>





我创建了一个单个标签字段用于保存您的值,按下标签旁边的按钮,您可以根据您的要求增加控件数量。



也可以看到它可能有帮助的链接

http:// ms dn.microsoft.com/en-us/library/bb288032.aspx [ ^ ]





希望有帮助



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


<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>


<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 [ ^ ]


这篇关于如何使用c#在asp.net中的每一行的gridview中添加按钮字段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆