ybt
asked on
How to change text on a link button dynamically
ASP.NET, C#
I have a link button in a repeater:
<th class="auto-style7">
<br /><br />
<asp:LinkButton ID="lnkreq_policy" runat="server" Text="Policy No" ForeColor="gray" OnClick="lnkreq_policy_cli ck" >
</asp:LinkButton>
</th>
to sort by this column, code behind:
protected void lnkreq_policy_click(object sender, EventArgs e)
{
ls_sort = "policy";
f_sorting(ls_sort);
}
how to change a link button text to: "asc Policy_no"
I have a link button in a repeater:
<th class="auto-style7">
<br /><br />
<asp:LinkButton ID="lnkreq_policy" runat="server" Text="Policy No" ForeColor="gray" OnClick="lnkreq_policy_cli
</asp:LinkButton>
</th>
to sort by this column, code behind:
protected void lnkreq_policy_click(object
{
ls_sort = "policy";
f_sorting(ls_sort);
}
how to change a link button text to: "asc Policy_no"
ASKER
I tried this way, but this link button in a header of repeater and this did not compiled
Is there some errors after compilation? Can you post it here?
Also try to remove
Also try to remove
'EnableViewState = "False"
on your gridview.
ASKER
This is not gridview, this is repeater, and error "The name 'lnkreq_policy' does not exist in the current context"
Ok, it this case try this code:
protected void lnkreq_policy_click(object sender, EventArgs e)
{
LinkButton Yourbutton = sender as LinkButton;
Yourbutton .Text = "asc Policy_no";
}
ASKER
No error now, but text did not change
it's not clear....
May be this answer can help you:
https://www.experts-exchange.com/questions/23409860/asp-net-linkbutton-in-repeater-dynamically-create-linkbutton-text-field-value.html
Also you can try this approach:
You can handle the ItemDataBound event for your dataRepeater.
In the event handler you can check
use code
LinkButton.
And then cahnge property Text..
May be this answer can help you:
https://www.experts-exchange.com/questions/23409860/asp-net-linkbutton-in-repeater-dynamically-create-linkbutton-text-field-value.html
Also you can try this approach:
You can handle the ItemDataBound event for your dataRepeater.
In the event handler you can check
e.Item.ItemType
and if it is your Header you canuse code
e.Item.FindControl("lnkreq_policy")
to get a reference to theLinkButton.
And then cahnge property Text..
This question needs an answer!
Become an EE member today
7 DAY FREE TRIALMembers can start a 7-Day Free trial then enjoy unlimited access to the platform.
View membership options
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Open in new window
If I correct understand you...