文章详情

  • 游戏榜单
  • 软件榜单
关闭导航
热搜榜
热门下载
热门标签
php爱好者> php文档>GridVew linkbutton点击时获取点击行label的绑定值

GridVew linkbutton点击时获取点击行label的绑定值

时间:2011-05-12  来源:高兴happy

点击按钮事件

 protected void LinkBtnUpdate_Click(object sender, EventArgs e)
{

LinkButton btn
= (LinkButton)sender;
//找到点击行
GridViewRow irow = (GridViewRow)btn.NamingContainer;
Label lbltag
= (Label)irow.Cells[0].FindControl("Label1");
string tbtag = lbltag.Text.Trim();
Response.Write(tbtag);
Response.Redirect(
"Update.aspx?url=news1.aspx&NewsType=1&NewsId=" + tbtag + "");
}

前台绑定:

<asp:GridView ID="GridTitle" runat="server" AutoGenerateColumns="False" 
CellPadding
="4" ForeColor="#333333" Width="100%"
AllowPaging
="True" AllowSorting="True"
onrowdatabound
="GridTitle_RowDataBound"
onpageindexchanging
="GridTitle_PageIndexChanging" PageSize="10" >
<RowStyle BackColor="#EFF3FB" />
<Columns>
<asp:TemplateField>
<HeaderTemplate>
序号
</HeaderTemplate>
<ItemTemplate>
<%# Container.DataItemIndex + 1%>
</ItemTemplate>
<ControlStyle Width="20px" />
<ItemStyle Width="70px" />
</asp:TemplateField>
<asp:BoundField DataField="NewsTitle" HeaderText="标题">
<ControlStyle Width="70%" />
</asp:BoundField>
<asp:TemplateField>
<HeaderTemplate>
操作
</HeaderTemplate>
<ItemTemplate>
<asp:LinkButton ID="LinkBtnUpdate" runat="server" onclick="LinkBtnUpdate_Click">编辑</asp:LinkButton>
&nbsp;
<asp:LinkButton ID="LinkBtnDelete" runat="server"
onclick
="LinkBtnDelete_Click" >删除</asp:LinkButton>
</ItemTemplate>
<ItemStyle Width="100px" />
</asp:TemplateField>
<asp:TemplateField Visible="false">
<ItemTemplate>
<asp:Label ID="Label1" runat="server" Text='<%#Eval("NewsId") %>'>&apos;&gt;</asp:Label>
</ItemTemplate>
</asp:TemplateField>
</Columns>
<FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
<PagerTemplate>
<table align="center" width="400px">
<tr>
<td width="50px">
<asp:Label ID="Label1" runat="server"
Text
="<%# ((GridView)Container.Parent.Parent).PageIndex + 1 %>" />

</td>
<td width="50px">
/<asp:Label ID="lblPageCount" runat="server"
Text
="<%# ((GridView)Container.Parent.Parent).PageCount %>" />

</td>
<td width="50px">
<asp:LinkButton ID="btnFirst" runat="server" CausesValidation="False"
CommandArgument
="First" CommandName="Page" Text="首页" />
</td>
<td width="50px">
<asp:LinkButton ID="btnPrev" runat="server" CausesValidation="False"
CommandArgument
="Prev" CommandName="Page" Text="上一页" />
</td>
<td>
<asp:LinkButton ID="btnNext" runat="server" CausesValidation="False"
CommandArgument
="Next" CommandName="Page" Text="下一页" />
</td>
<td width="50px">
<asp:LinkButton ID="btnLast" runat="server" CausesValidation="False"
CommandArgument
="Last" CommandName="Page" Text="尾页" />
</td>
</tr>
</table>
</PagerTemplate>
<PagerStyle ForeColor="White" HorizontalAlign="Center" />
<SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" />
<HeaderStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
<EditRowStyle BackColor="#2461BF" />
<AlternatingRowStyle BackColor="White" />
</asp:GridView>
相关阅读 更多 +
排行榜 更多 +
辰域智控app

辰域智控app

系统工具 下载
网医联盟app

网医联盟app

运动健身 下载
汇丰汇选App

汇丰汇选App

金融理财 下载