Click here to Skip to main content
16,009,156 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I want to add link button in ListView/ListBox/GridView while my page is loaded, in the Page_Load() events I want to query data from database and if I get 1 data than I'll add 1 LinkButton if I get 2 data than I'll add 2 LinkButton in this way I want add more linkbutton depends on query.
It's easy for me to query but, after getting information about my data I can't add LinkButton for this respect.
Such as: I have a table with 10 rows and 2 column. My query's result is 2 row which is in dataset's table. Now, I want to add 2 LinkButton with the info of two rows.

Please help me.
Posted
Comments
I.explore.code 12-Aug-12 17:34pm    
try using a template field for GridView and in the item template you can define any control you want.

1 solution

For example add your link button to TemplateField and you can add command argument and implement GridViewRowCommand and take appropriate action based on CommandName.


ASP.NET
<asp:templatefield headertext="Payer" controlstyle-width="100%" xmlns:asp="#unknown">
                                   <itemtemplate>
                                      <asp:linkbutton id="lbPayer" runat="server" text="<%# Eval("Payer") %>" commandargument="<%# Eval("Payer") %>" commandname="ViewPayer"></asp:linkbutton>
                                       </itemtemplate>
                                       <controlstyle width="100%"></controlstyle>
                               </asp:templatefield>
 
Share this answer
 

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