Using Dropdownlist in a gridview Asp.Net?

后端 未结 3 1584
栀梦
栀梦 2021-01-24 05:06

I want to use a dropdownlist on a gridview... I have the following code from asp.net



        
3条回答
  •  攒了一身酷
    2021-01-24 05:49

    This is what I did that worked for me:
    
    **Snippet from aspx:**
    
      
         
            
                                
      
    
    **Snippet from code-behind:**
    
     protected void grdSAEdit_RowUpdating(object sender, GridViewUpdateEventArgs e)
            {
                //Get the refernce to the list control
                DropDownList ddlRecStatus = (DropDownList)(grdSAEdit.Rows[e.RowIndex].FindControl("ddlRecStatus"));
    
                // Add it to the parameters
                e.NewValues.Add("RECORD_STATUS", ddlRecStatus.Text);
    
            }
    
            protected string[] Recs_Status
            {
                get { return new string[] {  "A", "E", "V", "Z" }; }
            }
    
            protected int GetselectedRecStatus(object status)
            {
                return Array.IndexOf(Recs_Status, status.ToString());
            }
    

提交回复
热议问题