0

在 datalist 命令 feild 我写过这样的代码

protected void DataListShowImgTxt_ItemCommand(object source, DataListCommandEventArgs e)
{
    string id = DataListShowImgTxt.DataKeys[e.Item.ItemIndex].ToString();
    //DataListItem tem = DataListShowImgTxt.Items[e.Item.ItemIndex] as DataListItem;
    //TextBox txtcmnet = tem.FindControl("txtcomment") as TextBox;
    createDt.commonAll("Select UserName from imagedb where imgid='" + id + "'", "searchimage");
    string u_name = createDt.GroupDS.Tables["searchimage"].Rows[0]["UserName"].ToString();


    if (e.CommandName == "SaveImage")
    {
        clickpic =Convert.ToInt32(DataListShowImgTxt.DataKeys[e.Item.ItemIndex].ToString());

        DataListItem teme = DataListShowImgTxt.Items[e.Item.ItemIndex] as DataListItem;
        ImageButton imgbtn = teme.FindControl("Image3") as ImageButton;
        imglightbox.ImageUrl = imgbtn.ImageUrl;
        ScriptManager.RegisterStartupScript(Page, typeof(Page), "ShowValidation", "javascript:ShowImages();", true);
        hovercoment(clickpic);
        showhoverlikComment(clickpic);


    }

     if (e.CommandName == "like")
    {
        ////string id = DataListShowImgTxt.DataKeys[e.Item.ItemIndex].ToString();
        createDt.commonAll("insert into likeimgdb(ImgId,UserName,LikeUser,Status,LikeImgDate) values('" + id + "','" + LoginUser + "','" + u_name + "','Like','"+DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")+"')", "insertimage");
        //LinkButton st = tem.FindControl("LinkButton8") as LinkButton;
         if (flag == 0)
        {
            ShowAllFriendsImage1(LoginUser); 
        }
        else if (flag == 1) {
            ShowAllFriendsImage(selectUser);
        }

    }

我只想在命令名称不是命令名称为 saveimage 时刷新我的网页

所以请指导我如何刷新它

其实我的设计是这样的

                                                                                            <asp:LinkButton ID="LinkButton1" runat="server" PostBackUrl='<% #Eval("Photo")%>' >
                                                                                            <asp:Image ID="Image2" runat="server" ImageUrl='<% #Eval("Photo")%>' Height="60px"
                                                                                                Width="65px" />
                                                                                         </asp:LinkButton>
                                                                                    </td>
                                                                                    <td style="width: 85%">
                                                                                        <asp:LinkButton ID="LinkButton3" runat="server" CommandName="PrfileFName" CssClass="ppppp">
                                                                                            <asp:Label ID="Label1" runat="server" Text='<% #Eval("FullName")%>'></asp:Label>
                                                                                        </asp:LinkButton>
                                                                                    </td>
                                                                                </tr>
                                                                                <tr>
                                                                                    <td style="width: 15%">
                                                                                    </td>
                                                                                    <td style="width: 85%">
                                                                                        <asp:LinkButton ID="LinkButton8" runat="server" CommandName="SaveImage" CssClass="ppppp">
                                                                                           save
                                                                                            <asp:ImageButton ID="Image3" runat="server" ImageUrl='<% #Eval("Image")%>' Height="250px"
                                                                                                Width="320px" />
                                                                                        </asp:LinkButton>
                                                                                    </td>
                                                                                </tr>
                                                                                <tr>
                                                                                    <td style="width: 15%">
                                                                                    </td>
                                                                                    <td style="width: 85%">
                                                                                        <asp:LinkButton ID="LinkButton9" runat="server" CommandName="like" ToolTip="Like This"
                                                                                            CssClass="qqq">Like</asp:LinkButton>&nbsp;<asp:Label ID="Label5" runat="server"></asp:Label>&nbsp;<asp:LinkButton
                                                                                                ID="LBComnt" runat="server" ToolTip="Leave a Comment" CommandName="Comment" CssClass="qqq">Comment</asp:LinkButton>&nbsp;<asp:Label
                                                                                                    ID="Label4" runat="server" Text='<% #Eval("AddDate")%>'></asp:Label>
                                                                                    </td>
                                                                                </tr>
                                                                                <%-- comee--%>
                                                                                <tr>
                                                                                    <td style="width: 15%">
                                                                                    </td>
                                                                                    <td style="width: 85%">

                                                                                        <asp:DataList ID="DataListLikeComnt" runat="server" CssClass="datalistborder" Width="308px">
                                                                                            <ItemTemplate>
                                                                                                <table width="100%">
                                                                                                    <tr>
                                                                                                        <td style="width: 15%" align="right">
                                                                                                            <asp:ImageButton ID="likeimagebutton" runat="server" ImageUrl="~/ProfileImage/like.jpeg"
                                                                                                                Width="30%" Height="30%" />
                                                                                                        </td>
                                                                                                        <td style="width: 85%">
                                                                                                            <asp:LinkButton ID="LblLike" runat="server" Text='<% #Eval("CountLike")%>' CssClass="qqq"></asp:LinkButton>
                                                                                                            <asp:Label ID="Label6" runat="server" Text="People Likes" CssClass="www"></asp:Label>
                                                                                                        </td>
                                                                                                    </tr>
                                                                                                    <tr>
                                                                                                        <td style="width: 15%" align="right">
                                                                                                            <asp:ImageButton ID="ImageButton2" runat="server" ImageUrl="~/images/internet_group_chat.png"
                                                                                                                Width="30%" Height="30%" />
                                                                                                        </td>
                                                                                                        <td style="width: 85%">
                                                                                                            <asp:LinkButton ID="Lblcoment" runat="server" Text='<% #Eval("CountComment")%>' CssClass="qqq"></asp:LinkButton>
                                                                                                            <asp:Label ID="Label7" runat="server" Text="People Comments" CssClass="www"></asp:Label>
                                                                                                        </td>
                                                                                                    </tr>
                                                                                                </table>
                                                                                            </ItemTemplate>
                                                                                        </asp:DataList>

                                                                                    </td>
                                                                                </tr>
                                                                                <tr>
                                                                                    <td style="width: 15%">
                                                                                    </td>
                                                                                    <td style="width: 85%">
                                                                                        <asp:DataList ID="DataListShowComment" runat="server" CssClass="datalistborder" Width="300px">
                                                                                            <ItemTemplate>
                                                                                                <table width="100%" style="background-color: #e9edf1;">
                                                                                                    <tr>
                                                                                                        <td style="width: 15%">
                                                                                                            <asp:LinkButton ID="LinkButton8" runat="server" CssClass="ppppp" CommandName="CommentProfImage">
                                                                                                                <asp:Image ID="Image3" runat="server" ImageUrl='<% #Eval("Photo")%>' Height="30px"
                                                                                                                    Width="30px" />
                                                                                                            </asp:LinkButton>
                                                                                                        </td>
                                                                                                        <td style="width: 85%">
                                                                                                            <table width="100%">
                                                                                                                <tr>
                                                                                                                    <td>
                                                                                                                        <asp:LinkButton ID="LBProfileImage" runat="server" CssClass="ppppp">
                                                                                                                            <asp:Label ID="Label1" runat="server" CssClass="www" Text='<% #Eval("FullName")%>'></asp:Label>
                                                                                                                        </asp:LinkButton>&nbsp;<asp:Label ID="Label8" runat="server" CssClass="www" Text='<% #Eval("Comment")%>'></asp:Label>
                                                                                                                    </td>
                                                                                                                </tr>
                                                                                                                <tr>
                                                                                                                    <td>
                                                                                                                    </td>
                                                                                                                </tr>
                                                                                                            </table>
                                                                                                        </td>
                                                                                                    </tr>
                                                                                                </table>
                                                                                            </ItemTemplate>
                                                                                        </asp:DataList>
                                                                                    </td>
                                                                                </tr>
                                                                            </table>
                                                                        </ItemTemplate>
                                                                    </asp:DataList>

我想在命令名 =SaveImage 上打开图像并更新命令名称上的计数器 = 类似这两者都工作正常,但是当我点击它移动到页面的开始位置时,我希望它只更新不移动的计数开始时

4

1 回答 1

0

用它 ,

Response.Redirect(Request.RawUrl);

将此代码放在您的条件下,

 if (e.CommandName == "like")
{
    ////string id = DataListShowImgTxt.DataKeys[e.Item.ItemIndex].ToString();
    createDt.commonAll("insert into likeimgdb(ImgId,UserName,LikeUser,Status,LikeImgDate) values('" + id + "','" + LoginUser + "','" + u_name + "','Like','"+DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")+"')", "insertimage");
    //LinkButton st = tem.FindControl("LinkButton8") as LinkButton;
     if (flag == 0)
    {
        ShowAllFriendsImage1(LoginUser); 
    }
    else if (flag == 1) {
        ShowAllFriendsImage(selectUser);
    }

Response.Redirect(Request.RawUrl);

}
于 2013-06-27T06:04:24.917 回答