Search code examples
c#asp.netajaxgridviewmodalpopupextender

Detailsview on ModalPopUp only displays first row of gridview


I have a detailsview inside a modalpopup that is supposed to be displaying the selected row in my gridivew, but it is only displaying the first row in my gridview. What am I doing incorrectly? Thank you for your help.

 protected void gvStudent_SelectedIndexChanged(object sender, EventArgs e)
    {

        this.dvstudent.Visible = true;
        this.dvstudent.DataBind();
        this.UpdatePanelDetailsView1.Update();
        this.modalstudent.Show();


    }
 protected void Selecttomodifystudent_Click(object sender, EventArgs e)
    {
        LinkButton buttonstudent = sender as LinkButton;
        GridViewRow row = (GridViewRow)buttonstudent.NamingContainer;
        this.sqlModifyStudent1.SelectParameters.Clear();
        this.dvstudent.DataBind();
        this.UpdatePanelDetailsView1.Update();
        this.modalstudent.Show();
    }

Solution

  • I found the answer to my problem. It was right before my eyes:

    protected void gvStudent_SelectedIndexChanged(object sender, EventArgs e)
        {
            dvstudent.PageIndex = gvStudent.SelectedIndex;
        }