protected void dl_Bangding_Load(object sender, EventArgs e)
{
for (int i = 0; i < dl_Bangding.Items.Count; i++)
{
TabContainer l = dl_Bangding.Items[i].FindControl("TabContainer1") as TabContainer;
Label dd= l.Controls[2] as Label;
//l.FindControl("lbl_Lmobil") ;
dd.Text = "sdafsadf";
}
}
datalist 中有TabContainer 控件 但是TabContainer中还有一个lable控件 怎么样才能找到lable 这个控件
{
for (int i = 0; i < dl_Bangding.Items.Count; i++)
{
TabContainer l = dl_Bangding.Items[i].FindControl("TabContainer1") as TabContainer;
Label dd= l.Controls[2] as Label;
//l.FindControl("lbl_Lmobil") ;
dd.Text = "sdafsadf";
}
}
datalist 中有TabContainer 控件 但是TabContainer中还有一个lable控件 怎么样才能找到lable 这个控件
里面 就有
http://blog.csdn.net/nandou1989/archive/2010/01/01/5117345.aspx
DataList应该一样,代码贴上,希望对你适用。 protected void rptypelist_ItemDataBound(object sender, RepeaterItemEventArgs e)
{
//判断里层repeater处于外层repeater的哪个位置( AlternatingItemTemplate,FooterTemplate,
//HeaderTemplate,,ItemTemplate,SeparatorTemplate)
if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
{
Repeater rep = e.Item.FindControl("rpquestionlist") as Repeater;//找到里层的repeater对象
DataRowView rowv = (DataRowView)e.Item.DataItem; //找到分类Repeater关联的数据项
int typeid = Convert.ToInt32(rowv["MsgID"]); //获取填充子类的id
rep.DataSource = SqlDataProvider.GetResultBySql("SELECT ReplayID, DisplayName,WallContent, ReplayTime, MsgID FROM Wall WHERE PreviousID = "+typeid+" ORDER BY MsgID DESC");
rep.DataBind();
}
}
rep是里面嵌套的控件。
在Repeater控件的ItemDataBound事件里写代码去找你要找的控件。
你的当然就是DataList的ItemDataBound事件里去找咯。
Repeater rep = e.Item.FindControl("rpquestionlist") as Repeater;//找到里层的repeater对象。基本上会是这句,自己搞定一下。
Label dd= l.Controls[2] as Label;
你确定LABEL的索引是2?
你还是遍历TabContainer判断是否有个LABEL控件吧。
{
if (e.CommandName=="Quite")
{
string str = dlstFriend.DataKeys[e.Item.ItemIndex].ToString();
int ID = int.Parse(str);
blog.Model.Friend FModel = friendBLL.GetModel(ID);
friendModel.friendID = FModel.FuserID;
friendModel.UID = FModel.UID;
friendModel.FuserID = FModel.FuserID;
DropDownList ddl=(DropDownList)e.Item.FindControl("ddlClass");
friendModel.friendClassID =Convert.ToInt32(ddl.SelectedValue);
friendModel.show = FModel.show;
friendModel.addTime = FModel.addTime;
try
{
friendBLL.Update(friendModel);
LTP.Common.MessageBox.Show(this, "移动成功");
}
catch (Exception ex)
{
string Error = ex.ToString();
throw;
}
}
else if (e.CommandName=="Delete")
{
string str = dlstFriend.DataKeys[e.Item.ItemIndex].ToString();
int ID = int.Parse(str);
try
{
friendBLL.Delete(ID);
LTP.Common.MessageBox.Show(this, "删除成功");
}
catch (Exception ex)
{
string Error = ex.ToString();
throw;
}
}
}