Click here to Skip to main content
13,150,178 members (60,380 online)
Rate this:
Please Sign up or sign in to vote.
See more:
i have gridview. and i want to show 3 links accept, confirm,decline in one headertext:action.when i click on accept link that time it should change in accepted.
Posted 30-Dec-12 18:30pm
Updated 30-Dec-12 18:31pm

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

use the following code

<asp:TemplateField HeaderText="Action">
                    <asp:LinkButton ID="lnkaccept" runat="server" Text="Accept" CommandName="Accept"></asp:LinkButton>&nbsp; | &nbsp;
                    <asp:LinkButton ID="lnkconfirm" runat="server" Text="Confirm" CommandName="Confirm"></asp:LinkButton>&nbsp; | &nbsp;
                    <asp:LinkButton ID="lnkdecline" runat="server" Text="Decline" CommandName="Decline"></asp:LinkButton>

test.aspx.cs file

protected void test_RowCommand(object sender, GridViewCommandEventArgs e)
            if (e.CommandName == "Accept")
                GridViewRow row = (GridViewRow)((LinkButton)(e.CommandSource)).NamingContainer;
                LinkButton lnkAccept = (LinkButton)row.FindControl("lnkaccept");
                    //do your task here
                    lnkAccept.Text = "Accepted";
                catch (Exception ex)
                    lnkAccept.Text = "Accept";
Member 9027346 31-Dec-12 2:27am
it works..but if i again run this program it again showing accept.i want to show accepted still not changing the record from database..
Vishal.Shimpi144 31-Dec-12 3:02am
use row databound event in the check the rowtype if it is datarow the check your condition if your condition is true the make link button text as Accepted like:
protected void test_RowDataBound(object sender, GridViewRowEventArgs e)
if (e.Row.RowType == DataControlRowType.DataRow)

if (check The condition here)
LinkButton lnk = (LinkButton)e.Row.FindControl("lnkaccept");
lnk.Text = "Accepted";

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

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy |
Web03 | 2.8.170924.2 | Last Updated 31 Dec 2012
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100