嵌套列表视图
我有列表视图,在lisetview中我有另一个列表vie,如嵌套列表视图 lv1--> lv2 和 lv2 内部我有按钮,当我单击按钮而不是插入模板显示时,但如何精细控制 lv2 ....?这是我的代码
Lv1 正常工作,但 lv2 出现问题..?
protected void lv1_ItemCommand(object sender, ListViewCommandEventArgs e)
{
if (e.CommandName == "NewRecord")
{
lv1.InsertItemPosition = InsertItemPosition.FirstItem;
}
}
protected void lv2_ItemCommand(object sender, ListViewCommandEventArgs e)
{
if (e.CommandName == "NewRecord")
{
//ListView lv2 = (ListView)e.Item.FindControl("lv2");
//lv2.InsertItemPosition = InsertItemPosition.FirstItem;
}
}
i have list view and inside lisetview i have another list vie like nested listview
lv1 --> lv2 and inside lv2 i have button when i'll click buttion than insert template show but how can fine control lv2 ....? there is my code
Lv1 is working but lv2 is creating problem..?
protected void lv1_ItemCommand(object sender, ListViewCommandEventArgs e)
{
if (e.CommandName == "NewRecord")
{
lv1.InsertItemPosition = InsertItemPosition.FirstItem;
}
}
protected void lv2_ItemCommand(object sender, ListViewCommandEventArgs e)
{
if (e.CommandName == "NewRecord")
{
//ListView lv2 = (ListView)e.Item.FindControl("lv2");
//lv2.InsertItemPosition = InsertItemPosition.FirstItem;
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
实际上,您可以通过转换
sender
参数轻松访问 lv2 控件:Actually, you can easily access your lv2 control by casting
sender
argument:嘿,哈利,我想我很了解瓦卡瓦卡!!
首先,您确定项目模板中的第二个列表视图???
或者是在选择、编辑或插入模板中???
如果它在项目模板中,那么:
要找到第二个列表视图,您应该使用以下代码:
在 vb.net 中:
在 c# 中:
然后您必须在 lv2 中找到按钮
,然后您可以
看到这是 vb.net 中的代码
,您可以在 C# 中看到此代码:
此示例中有很多示例可以了解如何操作在列表视图中找到一个控件,
谢谢,祝你好运。
hey Hary i think i know very well waqa waqa!!
First of all ,are you sure that the second list view in the item template???
or is it in the select , edite Or insert template ???
if it's in the item template then :
to find the second list view you should use this code :
in vb.net:
in c# :
then you have to find your button inside that lv2
then you can
see this is the code in vb.net
and you can see this code in C#:
there are lots of example in this sample to know how to find a control in list view
thanks and good luck for you.