移动到 datalist2 后如何禁用 datalist1 中的图像?

发布于 2024-12-09 13:05:58 字数 3218 浏览 2 评论 0原文

我有 2 个数据列表和 2 个向上和向下按钮,我试图将选定的图像从一个数据列表移动到另一数据列表。

Datalist1:

  <asp:DataList ID="dlstImage" runat="server" RepeatDirection="Horizontal" RepeatColumns="5"
                                CellSpacing="8" >
    <ItemTemplate>
         <asp:ImageButton ID="Image" runat="server" ImageUrl='<%#"~/Controls/ShowImage.ashx?FileName=" +DataBinder.Eval(Container.DataItem, "FilePath") %>'
                 OnCommand="Select_Command" CommandArgument='<%# Eval("Id").ToString() +";"+Eval("FilePath")+";"+Eval("Index")+";"+Eval("FileName") %>' /><br />
         <asp:Label ID="lbl" runat="server" Text="Figure"></asp:Label><%# dlstImage.Items.Count + 1%>
     </ItemTemplate>
   </asp:DataList>

Button:

<asp:ImageButton ID="ibtnMoveDown" runat="server" ImageUrl="~/App_Themes/Default/Images/movedown.bmp"
                        ToolTip="MoveDown The Item" OnClick="ibtnMoveDown_Click" />
 <asp:ImageButton ID="ibtnMoveUp" runat="server" ImageUrl="~/App_Themes/Default/Images/moveup.bmp"
                        Style="height: 16px" ToolTip="MoveUp The Item" />

Datalist2:

   <asp:DataList ID="dlstSelectedImages" runat="server" RepeatDirection="Horizontal"
                                RepeatColumns="5" CellSpacing="8">
       <ItemTemplate>
           <asp:ImageButton ID="Image" runat="server" ImageUrl='<%#"~/Controls/ShowImage.ashx?FileName=" +DataBinder.Eval(Container.DataItem, "FilePath") %>' 
                        OnCommand="ImageSelect_Command" CommandArgument='<%# Eval("Id").ToString() +";"+Eval("FilePath")+";"+Eval("Index")+";"+Eval("FileName") %>' /><br />
           <asp:Label ID="nlbl" runat="server" Text="Figure"></asp:Label><%# dlstSelectedImages.Items.Count + 1%>
       </ItemTemplate>
     </asp:DataList>

Button Down 代码:

        ArrayList ImgArry = new ArrayList();
        path = objGetBaseCase.GetImages(TotImgIds);
        ImgArry.Add(SelImgId);
        ImgArry.Add(SelImgpath);//image name
        ImgArry.Add(SelImgName);//image path
        //path.Remove(ImgArry);
        List<ArrayList> t = new List<ArrayList>();
        if (newpath.Count > 0)
            t = newpath;
        t.Add(ImgArry);
        newpath = t;
        for (int i = 0; i < newpath.Count; i++)
        {
            ArrayList alst = newpath[i];
            newtb.Rows.Add(Convert.ToInt32(alst[0]), alst[1].ToString(), alst[2].ToString(), i);

        }
        dlstSelectedImages.DataSource = newtb;
        DataBind();

        path = objGetBaseCase.GetImages(TotImgIds);
        for (int i = 0; i < path.Count; i++)
        {
            ArrayList alst = path[i];
            tb.Rows.Add(Convert.ToInt32(alst[0]), alst[1].ToString(), alst[2].ToString(), i);

        }
        dlstImage.DataSource = tb;
        DataBind();

我正在从 datalist1 选择一张图像并传输到 datalist2,我能够将图像从一个数据列表移动到另一个数据列表,但我想要的是当我移动图像然后移动 Datalist1 图像时我移动的任何图像在移动到 datalist2 后都会在 Datalist1 中禁用,如何做到这一点,如何在移动到 datalist2 后禁用 datalist1 中的图像。

I have 2 datalist and 2 btn UP and Down, I am trying to move the selected Image from one datalist to other datalist.

Datalist1:

  <asp:DataList ID="dlstImage" runat="server" RepeatDirection="Horizontal" RepeatColumns="5"
                                CellSpacing="8" >
    <ItemTemplate>
         <asp:ImageButton ID="Image" runat="server" ImageUrl='<%#"~/Controls/ShowImage.ashx?FileName=" +DataBinder.Eval(Container.DataItem, "FilePath") %>'
                 OnCommand="Select_Command" CommandArgument='<%# Eval("Id").ToString() +";"+Eval("FilePath")+";"+Eval("Index")+";"+Eval("FileName") %>' /><br />
         <asp:Label ID="lbl" runat="server" Text="Figure"></asp:Label><%# dlstImage.Items.Count + 1%>
     </ItemTemplate>
   </asp:DataList>

Button:

<asp:ImageButton ID="ibtnMoveDown" runat="server" ImageUrl="~/App_Themes/Default/Images/movedown.bmp"
                        ToolTip="MoveDown The Item" OnClick="ibtnMoveDown_Click" />
 <asp:ImageButton ID="ibtnMoveUp" runat="server" ImageUrl="~/App_Themes/Default/Images/moveup.bmp"
                        Style="height: 16px" ToolTip="MoveUp The Item" />

Datalist2:

   <asp:DataList ID="dlstSelectedImages" runat="server" RepeatDirection="Horizontal"
                                RepeatColumns="5" CellSpacing="8">
       <ItemTemplate>
           <asp:ImageButton ID="Image" runat="server" ImageUrl='<%#"~/Controls/ShowImage.ashx?FileName=" +DataBinder.Eval(Container.DataItem, "FilePath") %>' 
                        OnCommand="ImageSelect_Command" CommandArgument='<%# Eval("Id").ToString() +";"+Eval("FilePath")+";"+Eval("Index")+";"+Eval("FileName") %>' /><br />
           <asp:Label ID="nlbl" runat="server" Text="Figure"></asp:Label><%# dlstSelectedImages.Items.Count + 1%>
       </ItemTemplate>
     </asp:DataList>

Button Down code:

        ArrayList ImgArry = new ArrayList();
        path = objGetBaseCase.GetImages(TotImgIds);
        ImgArry.Add(SelImgId);
        ImgArry.Add(SelImgpath);//image name
        ImgArry.Add(SelImgName);//image path
        //path.Remove(ImgArry);
        List<ArrayList> t = new List<ArrayList>();
        if (newpath.Count > 0)
            t = newpath;
        t.Add(ImgArry);
        newpath = t;
        for (int i = 0; i < newpath.Count; i++)
        {
            ArrayList alst = newpath[i];
            newtb.Rows.Add(Convert.ToInt32(alst[0]), alst[1].ToString(), alst[2].ToString(), i);

        }
        dlstSelectedImages.DataSource = newtb;
        DataBind();

        path = objGetBaseCase.GetImages(TotImgIds);
        for (int i = 0; i < path.Count; i++)
        {
            ArrayList alst = path[i];
            tb.Rows.Add(Convert.ToInt32(alst[0]), alst[1].ToString(), alst[2].ToString(), i);

        }
        dlstImage.DataSource = tb;
        DataBind();

I am selecting a image from datalist1 and transferring to datalist2, I am able to move the Image from one datalist to other datalist, But what I want is when I am moving the Image then Datalist1 Image which ever image I am moving that image get disable in Datalist1 after moving to datalist2, How to do that, how to disable the image in datalist1 after move to datalist2.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

山田美奈子 2024-12-16 13:05:58

您可能只需要在适当的时间调用 DataBind() 方法,即在加载两个单独的数组之后,例如

DataList1.DataBind();
DataList2.DataBind();

如果我正确理解的话应该可以正常工作

you probably jus need to call the DataBind() method at the proper time, which is after loading the two separate arrays like this

DataList1.DataBind();
DataList2.DataBind();

that should work fine if i am getting you correctly

浮生未歇 2024-12-16 13:05:58
protected void dlstImage_ItemDataBound(object sender, DataListItemEventArgs e)// for disabling the image after moving
    {
        ImageButton imgctrl = (e.Item.FindControl("Image") as ImageButton);
        string[] str = imgctrl.CommandArgument.ToString().Split(';');
        SelImgId = Convert.ToInt32(str[0]);
        if (newpath.Exists(delegate(ArrayList imageDetails) { return Convert.ToInt32(imageDetails[0]) == SelImgId; }))
        {
            imgctrl.Enabled = false;
            imgctrl.CssClass = "tdDisable";
        }
        else
        {
            imgctrl.Enabled = true;
            imgctrl.CssClass = "";
        }
    }
protected void dlstImage_ItemDataBound(object sender, DataListItemEventArgs e)// for disabling the image after moving
    {
        ImageButton imgctrl = (e.Item.FindControl("Image") as ImageButton);
        string[] str = imgctrl.CommandArgument.ToString().Split(';');
        SelImgId = Convert.ToInt32(str[0]);
        if (newpath.Exists(delegate(ArrayList imageDetails) { return Convert.ToInt32(imageDetails[0]) == SelImgId; }))
        {
            imgctrl.Enabled = false;
            imgctrl.CssClass = "tdDisable";
        }
        else
        {
            imgctrl.Enabled = true;
            imgctrl.CssClass = "";
        }
    }
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文