需求:我在RowCommand 中,
前台:
 <ItemTemplate>
                                    <asp:LinkButton ID="linkBtnEdit" runat="server" Text="编辑" CommandName="BtnEdit" CommandArgument='<%#Eval("Command") %>' OnClientClick="DivShow();">
<asp:LinkButton>

 </ItemTemplate>
OnClientClick="DivShow()"是客户端,弹出JQuery的dialog
后台:protected void GDVYWInstruct_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            ///编辑
            if (e.CommandName=="BtnEdit")
            {
                this.txtYWName.Text = "zhongkang";
                this.txtCode.Text = "12222222";
            }为什么this.txtYWName.Text = "zhongkang";
                this.txtCode.Text = "12222222";
这些值在弹出的dialog中都不显示呢?

解决方案 »

  1.   

    要清楚是先执行的OnClientClick,后执行的RowCommand,你这样做按道理说应该弹不出来这样试一下,删除OnClientClick中的DivShow(),在RowCommand 
    事件中动态调用DivShow()方法
      

  2.   

      function DivShow() {
                alert("123");
                $("#div1").dialog({
                    show: "explode", title: "添加业务指令", modal: true, width: 800, height: 300
                });
                $("#div1").parent().appendTo("#dialog_target");
            }Jqeruy代码
      

  3.   

    你要把值 传到dialog弹出的页面中。
      

  4.   

    txtYWName和txtCode的Text是在GDVYWInstruct_RowCommand事件中设置的,该事件只有在回发时才会执行。DivShow()是客户端方法,如果你在没有设置txtYWName和txtCode前就调用,肯定不会有东西了
      

  5.   

    动态调用,类似于下面这样:  protected void GDVYWInstruct_RowCommand(object sender, GridViewCommandEventArgs e)
      {
      ///编辑
      if (e.CommandName=="BtnEdit")
      {
          this.txtYWName.Text = "zhongkang";
          this.txtCode.Text = "12222222";
      
          if (!ClientScript.IsStartupScriptRegistered(this.GetType(), "showDiv"))
          {
              //最后一个参数是你要执行的js代码块或函数名称
               ClientScript.RegisterStartupScript(this.GetType(), "showDiv", "DivShow()"); 
          }
          //...
      }
      

  6.   

    是的,在dialog中,有多个Textbox,我就是把值放进这些Textbox中
      

  7.   


    对了,我的这个gridview中是放在 updatepanel 的无刷新控件中,应该把这个脚本修改一下把,否则不响应哦??
      

  8.   

    把参数放到DivShow方法里,在js里进行赋值
      

  9.   

     if (e.CommandName=="BtnEdit")
                {
                    zh = "zhongkang";                                if (!ClientScript.IsStartupScriptRegistered(this.GetType(), "showDiv"))
                    {
                        //最后一个参数是你要执行的js代码块或函数名称
                       // ClientScript.RegisterStartupScript(this.GetType(), "showDiv", "DivShow()");                    ScriptManager.RegisterClientScriptBlock(this.Page, this.GetType(), "alert", "DivShow()", true);                }                this.txtYWName.Text = "zhongkang";
                    this.txtCode.Text = "12222222";这样好像也不能实现哦!跪求
      

  10.   

    谢谢各位大哥大姐们,我解决了,3Q you everybody!等有时间在结贴。
    把参数放到DivShow方法里,在js里进行赋值----jaysea,谢谢你的思路!