【问题标题】:How to use modal pop up extender, inside the gridview image button?如何在gridview图像按钮内使用模态弹出扩展器?
【发布时间】:2015-12-23 23:22:51
【问题描述】:

作为标题,如何在gridview按钮中使用模态弹出扩展器。

在gridview中,按钮只是一个带有图像的普通按钮(我没有使用编辑模板添加按钮)。

现在我所做的是(根据在线资源),我在 gridview 上添加了一个事件。

protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.RowType == DataControlRowType.DataRow)
            {
                (e.Row.FindControl("lnkEdit") as Button).Attributes.Add("onClick", "ShowEditModal('" + ID + "');");

            }
        }

Showeditmodal 函数是 html 页面上的一个 javascript 函数,但问题是,我如何能够从 gridview 的不同行中获取不同的 ID,以根据 ID 弹出正确的模式?

【问题讨论】:

  • ID 究竟是什么?它是来自 GridView 的某一列的值吗?
  • 是的。你是对的,只是一个值
  • 然后在下面查看我的答案。

标签: javascript c# html asp.net ajax


【解决方案1】:

您可以通过e.Row.Cells获取它

protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
            {
                if (e.Row.RowType == DataControlRowType.DataRow)
                {
                    int idColumnNumber=1; // number of your id column
                    int id=Convert.ToInt32(e.Row.Cells[idColumnNumber].Text);
                    (e.Row.FindControl("lnkEdit") as Button).Attributes.Add("onClick", "ShowEditModal('" + id + "');");

                }
            }

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-01-02
    • 1970-01-01
    • 1970-01-01
    • 2016-11-29
    • 2012-10-22
    相关资源
    最近更新 更多