GridView中的问题,排开ModalPopupExtender的onclick [英] ModalPopupExtender open onclick of GridView row problems

查看:247
本文介绍了GridView中的问题,排开ModalPopupExtender的onclick的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

(我使用Lukinha RS的解决方案,该行的onclick功能)

当我在GridView我收到了回发ModalPopupExtender打开之前在某一行上单击,我不想回发但是当你看到我使用的方法是原因。不幸的是我已经能够得到一个onClick应用到一个gridview排开MPE的唯一途径。

我的另一个问题是与MPE开放 - 我点击它只是重新加载使用相同的弹出PANAL开放所产生的页面弹出一个PANAL关闭按钮

 保护无效GridView1_RowDataBound(对象发件人,GridViewRowEventArgs E)
{
    GridViewRow排= e.Row;
    如果(row.DataItem == NULL)
    {
        返回;
    }    尝试
    {
        开关(e.Row.RowType)
        {
            案例DataControlRowType.Header:
                打破;            案例DataControlRowType.DataRow:
                e.Row.Attributes.Add(的onmouseover,this.style.cursor ='手');
                e.Row.Attributes.Add(onclick事件,Page.ClientScript.GetPostBackEventReference(GridView1,选择$+ e.Row.RowIndex.ToString()));
                打破;
        }
    }    抓住
    {
        返回;
    }

和这里是我的SelectedIndexChanged

 保护无效GridView1_SelectedIndexChanged(对象发件人,EventArgs的发送)
{
    GridViewRow行=((GridView的)发件人).SelectedRow;
    ModalPopupExtender MPE =(ModalPopupExtender)row.FindControl(ModalPopupExtender1);
    mpe.Show();
}


解决方案

  

不幸的是我已经能够得到一个onClick的唯一途径
  适用于一个gridview行打开MPE


不正确。其实,你可以打开模式扩展没有回发。
更改的onclick 属性值如下:

  e.Row.Attributes.Add(onclick事件,的String.Format(JavaScript的:$找到('{0})显示();,ModalPopupExtender1.ClientID ));

(I'm using Lukinha RS's solution to the row onclick functionality)

When I click on a row within the gridview I get a postback before the ModalPopupExtender opens, I dont want the postback however as you see the method I use is the cause. Unfortunatly it is the only way I have been able to get an onClick applied to a gridview row to open the MPE.

Another problem I have is with the MPE open - I click a 'close' button on the popup panal it simply reloads the page resulting with the same popup panal opening.

 protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
    GridViewRow row = e.Row;
    if (row.DataItem == null)
    {
        return;
    }

    try
    {
        switch (e.Row.RowType)
        {
            case DataControlRowType.Header:
                break;

            case DataControlRowType.DataRow:
                e.Row.Attributes.Add("onmouseover", "this.style.cursor='hand'");
                e.Row.Attributes.Add("onclick", Page.ClientScript.GetPostBackEventReference(GridView1, "Select$" + e.Row.RowIndex.ToString()));
                break;
        }
    }

    catch
    {
        return;
    }

And here is my SelectedIndexChanged

    protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
{
    GridViewRow row = ((GridView)sender).SelectedRow;
    ModalPopupExtender mpe = (ModalPopupExtender)row.FindControl("ModalPopupExtender1");
    mpe.Show();
}

解决方案

Unfortunatly it is the only way I have been able to get an onClick applied to a gridview row to open the MPE

Incorrectly. Actually, you CAN open modal extender without postback. Change onclick attribute value as below:

e.Row.Attributes.Add("onclick", String.Format("javascript:$find('{0}').show();", ModalPopupExtender1.ClientID));

这篇关于GridView中的问题,排开ModalPopupExtender的onclick的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆