English 中文(简体)
根据另一个列表视图的选择更改列表视图中选择的项目。
原标题:
  • 时间:2009-03-11 12:11:26
  •  标签:

我有两个列表视图。在第一个列表视图的项命令事件中,我使用ajaxtoolkit在模态弹出窗口中显示第二个列表视图。

protected void lvSelection_ItemCommand(object sender, ListViewCommandEventArgs e)
{
    this.lvPopup.Visible = true;
    this.lvPopup.DataSource = linqdataSource;
    this.lvPopup.DataBind();

    this.mdlPopup.Show();
}

现在在第二个列表视图的项命令事件中,我需要更改第一个列表视图中所选项目的内容。

能做到吗?

问题回答
protected void lvPopup_ItemCommand(object sender, ListViewCommandEventArgs e)
{
    // Set the text of the first list view item to the selected item 
    // of the second list view.
    lstView1.Items[lstView1.SelectedIndex].Text = 
        lstView2.Items[lstView2.SelectedIndex].Text
}

我认为如果您将第一个 ListView 中选择器按钮的 CommandName 设置为 "选择" - 从第二个列表视图的 ItemCommand 事件,您应该能够更改第一个列表中所选项的 SelectedItemTemplate 或当前项。

protected void lvPopup_ItemCommand(object sender, ListViewCommandEventArgs e)
{

   lvSelection.SelectedItemTemplate = "<div>woohoo!</div>";
   // OR...
   lvSelection.Items[lvSelection.SelectedIndex].SkinID = "SomeNewSkinForExample";


   mdlPopup.Hide();

}

你已经尝试动态生成列表项了吗?

在第一个列表的事件代码中,清除第二个列表中的项目,并使用适合您的逻辑填充它。





相关问题
热门标签