项目模板的问题 [英] problem with item template
本文介绍了项目模板的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有gridview。并且我想显示3个链接接受,确认,拒绝一个headertext:action.when我点击接受链接那个时候应该改变接受。
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.
推荐答案
使用以下代码
test.aspx:
use the following code
test.aspx:
<asp:TemplateField HeaderText="Action">
<ItemTemplate>
<asp:LinkButton ID="lnkaccept" runat="server" Text="Accept" CommandName="Accept"></asp:LinkButton> |
<asp:LinkButton ID="lnkconfirm" runat="server" Text="Confirm" CommandName="Confirm"></asp:LinkButton> |
<asp:LinkButton ID="lnkdecline" runat="server" Text="Decline" CommandName="Decline"></asp:LinkButton>
</ItemTemplate>
</asp:TemplateField>
test.aspx.cs文件
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");
try
{
//do your task here
lnkAccept.Text = "Accepted";
}
catch (Exception ex)
{
lnkAccept.Text = "Accept";
}
}
}
这篇关于项目模板的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文