datalist中有一个linkbutton现在需要获取linkbutton的文本内容。现在我获取的是null值
能帮下忙吗

解决方案 »

  1.   

    不知道你具体想说什么,把数据绑定到linkbutton的text属性上不就行了么...
      

  2.   

    找不到
     protected void dlcent_ItemDataBound(object sender, DataListItemEventArgs e)
        {        //LinkButton btn = e.Item.FindControl("lbzname") as LinkButton;
            //string cid = sqloperat.CheckUserID(btn.Text);
            //Response.Redirect("indexfriend.aspx?cid=" + Convert.ToInt32(cid));
            //Response.Write(btn.Text);  
        }
    是空值
      

  3.   

    现在需要获取linkbutton的文本内容。
    ==
    要看是什么对象的什么事件获取
      

  4.   

    to amandag :
    请问你如何写
     我写出来获取的是空值
      

  5.   

     FindControl方法后加一个是否null的判断,看是否找到控件了
    如果找到了就应该可以获取到Text值
      

  6.   

    加一个判断,因为表头表尾是没有那个LinkButton
            if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
            {
            //LinkButton btn = e.Item.FindControl("lbzname") as LinkButton; 
            //string cid = sqloperat.CheckUserID(btn.Text); 
            //Response.Redirect("indexfriend.aspx?cid=" + Convert.ToInt32(cid)); 
            //Response.Write(btn.Text);  
            }
      

  7.   

    protected void dlcent_ItemDataBound(object sender, DataListItemEventArgs e) 

       if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
       {
            //LinkButton btn = e.Item.FindControl("lbzname") as LinkButton; 
            //string cid = sqloperat.CheckUserID(btn.Text); 
            //Response.Redirect("indexfriend.aspx?cid=" + Convert.ToInt32(cid)); 
            //Response.Write(btn.Text);  
        }
    }