How to bind data to linkbutton without interfering with other related fields?

There are few gridviews on the page. The first gridview is being edited, the second is not. The first gridview has a column with a hyperlink (linkbutton). The second table should be loaded based on the click event of the hyperlink above. It looks like a hyperlink behaves like a button. It can be done?

To even try, I'm not sure where to start. I added a hyperlink to the first gridview column. But what I need for NavigationURL is doubtful.

There are only a few events in hyperlink management. enter image description here

None of this does what I need. Any tutorial is valuable.

Update: Gird Markup Code

<div id="schedule"> <asp:GridView ID="gvSchedule" runat="server" AutoGenerateColumns="false" CssClass="Grid" DataKeyNames="Employee ID, WOY, Location" ShowHeader="false" RowStyle-CssClass="rowstyle" onrowdatabound="gvSchedule_RowDataBound"> <Columns> <asp:BoundField HeaderText="Staff" DataField="E_Name" SortExpression="E_Name" ItemStyle-Width="113" /> </Columns> </asp:GridView> <br /> </div> 

Tried the link to here

 <asp:TemplateField HeaderText="StaffClick" SortExpression="STOCK NO" ItemStyle-Width="50"> <ItemTemplate> <asp:LinkButton ID="lblStaff" runat="server">Click</asp:LinkButton> </ItemTemplate> <HeaderStyle BackColor="Black" ForeColor="White" HorizontalAlign="Left"/> <ItemStyle HorizontalAlign="Left" /> </asp:TemplateField> 

After using this code, now none of the checkboxes are loaded with the rowbound event.

0
source share
1 answer

Put the LinkButton in your GridView and use the "RowCommand" action to set what is going to happen. As soon as the link is clicked, an event called RowCommand is dispatched. You can handle everything that should happen on the server side.

CommandArgument can be anything that you want to pass functions to the server side.

Here is an example:

  <asp:Button ID="btnViewmore" CommandArgument="<%# ((GridViewRow) Container).RowIndex %> " CommandName="More" runat="server" Text="View More" /> 

And on the server side you can do this (C #):

 protected void gridMembersList_RowCommand(object sender, GridViewCommandEventArgs e) { if (e.CommandName == "More") { int index = Convert.ToInt32(e.CommandArgument.ToString()); // do something with your command and commandargument, like for instance, update the second gridview } } 
0
source

Source: https://habr.com/ru/post/891762/


All Articles