asp.net怎样获取gridview里的控件label?
4个回答
展开全部
这个要分种情况,在不同的事件中有不同的获取方法。
protected void gv_order_RowUpdating(object sender, GridViewUpdateEventArgs e)
{
string buyCount = ((Label)gv_order.Rows[e.RowIndex].Cells[8].Controls[1].FindControl("lalBuycount")).Text;
——————————————————————————————————————
protected void gv_goning_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
if (e.Row.RowState == DataControlRowState.Normal || e.Row.RowState == DataControlRowState.Alternate)
{
string pid = e.Row.Cells[0].Text;
string hadpay = "select count(*) from gb_order where trade_status = 1 and pid=" + pid;
((LinkButton)e.Row.FindControl("lbHadpay")).Text = bc.sqlCount(hadpay).ToString() + "单";
建议你收索一下gridview 72搬绝技。介绍很全面。
protected void gv_order_RowUpdating(object sender, GridViewUpdateEventArgs e)
{
string buyCount = ((Label)gv_order.Rows[e.RowIndex].Cells[8].Controls[1].FindControl("lalBuycount")).Text;
——————————————————————————————————————
protected void gv_goning_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
if (e.Row.RowState == DataControlRowState.Normal || e.Row.RowState == DataControlRowState.Alternate)
{
string pid = e.Row.Cells[0].Text;
string hadpay = "select count(*) from gb_order where trade_status = 1 and pid=" + pid;
((LinkButton)e.Row.FindControl("lbHadpay")).Text = bc.sqlCount(hadpay).ToString() + "单";
建议你收索一下gridview 72搬绝技。介绍很全面。
展开全部
Label 目标Label=e.Row.FindControl('label名称') as Labe;
这句代码一般在 gridview的RowCommand事件中执行
这句代码一般在 gridview的RowCommand事件中执行
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
1 把Label放到模板列里
2 Dim gvr as GridViewRow
For each gvr in GridView1.Rows
Dim youresult as string=Ctype(gvr.FindControl("Label1"),Label).text
Next
2 Dim gvr as GridViewRow
For each gvr in GridView1.Rows
Dim youresult as string=Ctype(gvr.FindControl("Label1"),Label).text
Next
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
(Label)e.Row.FindControl("Label1")
(Label)GridView1.Rows[e.RowIndex].FindControl("Label1")
(Label)GridView1.Rows[e.RowIndex].FindControl("Label1")
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询