我的程序是主頁面放一個DataGrid,放員工信息,當然包括Empcode
現在就是要主管點一下該員工紀錄,然後按一下請假明細就彈出該員工的請假明細(子窗口)
點一下加班明細就彈出該員工的加班明細,現在功能已經都實現,但問題是每點一次
明細按鈕主頁面都要刷新,現在要求不能刷新應該怎麼作

解决方案 »

  1.   

    我觉得你用Page.RegisterStartupScript,本身就要求刷新才弹子窗口。为什么不在datagrid的数据binding时,对每一个btnHDetail(自定义模板的非服务器控件)的onclick的attribute加js呢?
      

  2.   

    billwang188()的话有道理,在绑定数据源的时候也可以用已赋值的超链接的方式来打开子窗口, 同时给onclick事件加JS代码,让他打开窗口.不一定非要用服务端控件.
      

  3.   

    同意 billwang188 的意见,我要做也这样,直接双击该行调出明细就完事拉,在绑定
    datagrid 时 加上客户端代码就是,非常简单,何必再用 button.
      

  4.   

    用showModalDialog(),不用btnHDetail_Click服务器控件,用客户端脚本onclick
      

  5.   

    因為我們公司要求同一個頁面要放加班,請假,異常,支援很多資料,導致有
    四五十列,根本就放不下Button列其實不用Button也可以,可以用HyperLink,但我不知道怎麼傳動態參數,
    HyperLink好像沒有事件可用
      

  6.   

    改在客户端打开子窗口,
    这段代码是用Empcode字段变成超级连接<ItemTemplate>
        <a href="javascript:window.showModalDialog('WebForm2.aspx?value=<%# DataBinder.Eval(Container, "DataItem.Empcode") %>', window,'');"> 
    <asp:Label runat="server" Text='<%# DataBinder.Eval(Container, "DataItem.title_id") %>'>
    </asp:Label>
       </a>
    </ItemTemplate>
      

  7.   

    再提供一段代码,你可以按照这样的思路改一下,就可以啦:
    --datagrid整一行都链接上某页,选中行变色
    private void DataGrid1_ItemDataBound(object sender, System.Web.UI.WebControls.DataGridItemEventArgs e)
    {
    if(e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
    {
    e.Item.Attributes.Add("onmouseout", "this.style.backgroundColor='#FFFFFF'")   ;
    e.Item.Attributes.Add("onmouseover", "this.style.backgroundColor='LightGoldenrodYellow'") ; 

    string ContractName = DataBinder.Eval(e.Item.DataItem, "au_id").ToString();
    string ContractID = DataBinder.Eval(e.Item.DataItem, "title_id").ToString();
    e.Item.Style["cursor"] = "hand";
    e.Item.ToolTip = ContractName;
    e.Item.ForeColor=Color.Blue;
    e.Item.Attributes.Add("onclick","window.open('webform1.aspx?value="+ContractID+"','_blank','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,revisable=no,left=100,top=0,width=600,height=450');");  
    }
    }
      

  8.   

    樓上說的我一直都是這樣做的,雙擊彈出窗口我知道怎麼做,
    但我想用Button表示比較清楚,不想用雙擊,因為那些
    主管都是電腦BC,你要他們雙擊他們會很不爽,
    如果用客戶端的Button控件應該怎麼接收事件
      

  9.   

    加个HTML按钮
    加入window.showModalDialog('WebForm2.aspx?value=Empcode);
    不就行了?
      

  10.   

    加个HTML按钮,把这些代码入在HTML按钮就行了,用客户端打开就不会有刷新的情况出现
    window.open('http://localhost/TAS/HolidayDetail.aspx?Empcode=" + txtEmpcode.Text + "&Year=" + txtYear.Text + "','請假明細', 'top=50,left=100,width=700,height=600,toolbar=0,location=0,directories=0,menubar=0,scrollbars=1,resizable=1,status=0');
      

  11.   

    private void Page_Load(object sender, System.EventArgs e)
    {
    if(!IsPostBack)
    {
    ArrayList al=new ArrayList();
    al.Add("aa");
    al.Add("bb");
    al.Add("cc");
    this.DataGrid1.DataSource=al;
    this.DataGrid1.DataBind();
    } }
    在datagrid 得事件中加上
    private void DataGrid1_ItemCreated(object sender, System.Web.UI.WebControls.DataGridItemEventArgs e)
    {
    e.Item.Cells[0].Attributes.Add("onclick","window.open('http://localhost/TAS/HolidayDetail.aspx?Empcode=" + this.innerText+','請假明細', 'top=50,left=100,width=700,height=600,toolbar=0,location=0,directories=0,menubar=0,scrollbars=1,resizable=1,status=0')");
    }
      

  12.   

    如果想要获取当前行某个单元的Text可用this.parentElement.cells(j).innerText 获取