datalist求助 datalist中有一个linkbutton现在需要获取linkbutton的文本内容。现在我获取的是null值能帮下忙吗 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 不知道你具体想说什么,把数据绑定到linkbutton的text属性上不就行了么... 找不到 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); }是空值 现在需要获取linkbutton的文本内容。==要看是什么对象的什么事件获取 to amandag :请问你如何写 我写出来获取的是空值 FindControl方法后加一个是否null的判断,看是否找到控件了如果找到了就应该可以获取到Text值 加一个判断,因为表头表尾是没有那个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); } 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); }} 怎样防止sql注入? 各位请进-FileUpload上传图片问题 VS2010 调试自动断开,跟定时了一样。郁闷。。。。 asp新闻自动采集 本人05年大专毕业,说来惭愧。刚毕业的时候由于没有实际经验没有公司肯收留我。为了生活我去做了软件安装维护,后来思前想后,做那活没有 往页面里写入html字符串,显示后出现乱码,在线等 探讨算法:城市公交的行车路径优化问题 如何利用正则表达式提取网页嵌套表格里的内容 在租用的空间里不能使用代码分离的页面怎么回事 ioffice-e调试中的一些问题,谁知道...(windfun(小宝.NET) 请进) 请教一条SQL String 字符串 插入子串的问题
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);
}
是空值
==
要看是什么对象的什么事件获取
请问你如何写
我写出来获取的是空值
如果找到了就应该可以获取到Text值
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);
}
{
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);
}
}