accessing dropdown inside child grid

Last post 05-13-2008 11:36 PM by Qin Dian Tang - MSFT. 2 replies.

Sort Posts:

  • accessing dropdown inside child grid

    05-09-2008, 9:15 AM

    Hi

    I have parent grid which is collapsable and inside that there is child grid. I have drop down control inside child contro for status. When I slect status in dropdown, it should update it accordingly. So I am trying following code.

    protected void ddlChildStatusType_SelectedIndexChanged(object sender, EventArgs e)

    {

    GridViewRow Rows = (GridViewRow)(((Control)sender).NamingContainer);GridView ChildGridView = ((GridView)gvMember.Rows[(Convert.ToInt32(Rows.RowIndex))].FindControl("gvChild"));

     

     

    //int i = ChildGridView.SelectedIndex;

    int childId = Convert.ToInt32(((Label)ChildGridView.Rows[(Convert.ToInt32(Rows.RowIndex))].FindControl("lblChildId")).Text);

    int statusId = Convert.ToInt32(((DropDownList)ChildGridView.Rows[(Convert.ToInt32(Rows.RowIndex))].FindControl("ddlChildStatusType")).SelectedValue);

    WiseHealth.Admin.BLL.Member.Member.UpdateMemberStatus(childId, statusId);

    //gvMember.DataBind();

    }

     

    here gVMember is my parent grid and gvChild is child grid,ddlChildStatusType is my dropdown. When I debug above code I find that Rows itself return result zero. But actually there is one row.I try to find out Rowcount it also return zero.

    Please help me to understnd and resolve this issue.

  • Re: accessing dropdown inside child grid

    05-13-2008, 11:34 PM

    Hi dnyandeo,

    Try this:

    GridViewRow Rows = (GridViewRow)((DropDownList)sender).Parent.Parent.Parent;  //I do not how many "Parent" you need in your situation, please try until you find GridViewRow in gVMember.

    Thanks,

    Please remember to click "Mark as Answer" on the post that helps you, and to click "Unmark as Answer" if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread.
  • Re: accessing dropdown inside child grid

    05-13-2008, 11:36 PM
    Answer

    Hi dnyandeo,

    You found you just need GridViewRow in gvChild, so try this:

    GridViewRow Rows = (GridViewRow)((DropDownList)sender).Parent;

    Thanks,

     

    Please remember to click "Mark as Answer" on the post that helps you, and to click "Unmark as Answer" if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread.
Page 1 of 1 (3 items)