Friday, 30 May 2014

Get Gridview RowIndex on Dropdownlist or Button event inside gridview in asp.net



//****************Dropdownlist SelectedIndexChanged Event

 protected void DropDownList_SelectedIndexChanged(object sender, EventArgs e)
    {
        DropDownList ddl = (sender) as DropDownList;
        GridViewRow drr = (GridViewRow)ddl.NamingContainer;
        int rnd = drr.RowIndex;      //Row Index

//Here is your code
}


//****************Button _Click Event
 protected void Button _Click(object sender, EventArgs e)
    {
 Button Btn= (sender) as Button ;
        GridViewRow drr = (GridViewRow)Btn.NamingContainer;
       int rnd = drr.RowIndex;      //Row Index

//Here is your code
}

No comments:

Post a Comment

How to highlight selected text in notepad++

  –> To highlight a block of code in Notepad++, please do the following steps step-1  :- Select the required text. step-2  :- Right click...