以模式显示gridview选定的行数据

时间:2019-06-20 10:55:59

标签: c# asp.net gridview bootstrap-modal entityobject

我是ASP.net的新人,并且正在使用gridview。 我从gridview内的sql server数据库加载数据。控件列也是动态创建的。现在,我想以自举模式显示所选行的内容(通过单击控制动作)。但是对于我的gridview的每一行,模式只显示最后一个gridview行的信息。 这是我的gridview rowdatabound事件处理程序的代码:

protected void cgvReferentiel_RowDataBound(object sender, GridViewRowEventArgs e)
{
        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            //Create object from row
            ReferentielEO ref = (ReferentielEO)e.Row.DataItem;

            //Add the profile link to the action column.
            HyperLink profileLink = new HyperLink();
            profileLink.Text = "Profil";
            profileLink.CssClass = "btn btn-info";
            profileLink.ToolTip = "User Profile "+ref.ID;

            //Opening modal from editlink
            profileLink.NavigateUrl = "#profil";
            profileLink.Attributes.Add("data-toggle", "modal");
            profileLink.Attributes.Add("data-target", "#profil");

            //Setting object attributes to the modal fields 
            lblId.Text=ref.IDENTIFIANT;         
            lblNom.Text = ref.NOM_SALARIE;
            lblSource.Text = ref.SOURCE;

        }
    }

Screenshot

0 个答案:

没有答案