本文介绍了中继器更新的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用中继器控件来显示记录,我正在使用javascript window.open编辑记录

我有一个问题,那就是当我第一次单击更新"按钮时,它没有打开窗口,第二次应单击该按钮.

为什么会出现此问题?

其次,我想知道在更新记录后如何重新绑定重复出现

第三,更新记录后如何关闭打开的JavaScript窗口
中继器项目命令===>

I am using a repeater control to display records,I m using javascript window.open to edit a record

I am having a problem in it that when i click on Update button first time it doesnot open window one should click second time on the button

Why is this problem arising?

Second i want to know how can i rebind repetear after updating the record

Third how can i close the opened javascript window just after updating record
Repeater Item Command ===>

<pre lang="cs">protected void rptuser_ItemCommand(object source, RepeaterCommandEventArgs e)
    {
        try
        {
            Usercls u = new Usercls();
            if (e.CommandName == "upd")
            {
                int uid = Convert.ToInt32(e.CommandArgument);
                Session["uid"] = u.GetUserbyID(uid)[0].UserId.ToString();
                Session["fname"] = u.GetUserbyID(uid)[0].FirstName;
                Session["lname"] = u.GetUserbyID(uid)[0].LastName;
                Session["uname"] = u.GetUserbyID(uid)[0].Username;
                Session["des"] = u.GetUserbyID(uid)[0].Designation;
                ImageButton upd = (ImageButton)e.Item.FindControl("updbtn");
                upd.OnClientClick = "return PopUp()";
            }
            else if (e.CommandName == "del")
            {
                int uid = Convert.ToInt32(e.CommandArgument);
                u.DeleteUser(uid);
                rptuser.DataBind();
            }
        }
        catch (Exception ex)
        {
            throw ex;
        }
    }




中继器===>




Repeater ===>

<pre lang="xml"><asp:Repeater ID="rptuser" runat="server" DataSourceID="ObjectDataSource1"
               OnItemCommand="rptuser_ItemCommand">
       <HeaderTemplate>
       <table>
       <tr>
       <td class="GridHeader"></td>
       <td  class="GridHeader">UserID:</td>
       <td class="GridHeader">FirstName:</td>
       <td class="GridHeader">LastName:</td>
       <td class="GridHeader">Designation:</td>
       <td  class="GridHeader">UserName:</td>
       <td class="GridHeader"></td>
       </tr>
       </HeaderTemplate>
       <ItemTemplate>
       <tr>
        <td class="GridItems"><asp:ImageButton runat="server" ID="delbtn" ImageUrl="~/images/delete.gif" CommandName="del" CommandArgument=''<%# Eval("UserId") %>'' OnClientClick="return confirm(''Are you sure to delete this User'')"  ValidationGroup="ab" ToolTip="Delete User"  /></td>
        <td class="GridItems"><%# DataBinder.Eval(Container.DataItem,"UserId") %></td>
        <td class="GridItems"><%# DataBinder.Eval(Container.DataItem,"FirstName") %></td>
        <td class="GridItems"><%# DataBinder.Eval(Container.DataItem,"LastName") %></td>
        <td class="GridItems"><%# DataBinder.Eval(Container.DataItem,"Designation") %></td>
        <td class="GridItems"><%# DataBinder.Eval(Container.DataItem,"Username") %></td>
        <td class="GridItems"><asp:ImageButton ID="updbtn"   ValidationGroup="Av" runat="server" ImageUrl="~/images/update.jpg"   CommandName="upd" CommandArgument=''<%# DataBinder.Eval(Container.DataItem,"UserId") %>'' /></td>
       </tr>
       </ItemTemplate>
       <FooterTemplate>
       </table>
       </FooterTemplate>
       </asp:Repeater>




如果我在转发器内部使用OnClientClick,则会出现异常,因为它找不到合适的会话对象




If i use OnClientClick inside repeater,it gives exception as it doesn''t find appropriate session object

推荐答案



private void Bind()
    {
        //connection command datatable...
        Repeater1.DataSource = dt;
        Repeater1.DataBind();
    }


3)在此处检查[a] [ ^ ]


3)Check here[^]


这篇关于中继器更新的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-24 01:47