How to enable in-place editing in an asp:GridView?

前端 未结 2 404
误落风尘
误落风尘 2021-01-05 18:19

How can i add edit boxes, and read their values during submit, with an asp:Repeater?


i have an asp:GridView which is displaying a rea

2条回答
  •  遥遥无期
    2021-01-05 18:51

    You can do this using a GridView, but you'll produce quite a lot of code if you have many columns.

    First make all columns in the GridView TemplateFields. In my sample I will use just one column. Like so:

    
        
            
                
                    
                
            
            
        
    
    
    

    Then in your code behind for the Save button you can iterate over the rows in the GridView:

    foreach (GridViewRow gvRow in test.Rows)
    {
        string val = ((TextBox)gvRow.FindControl("FooText")).Text;
        
        //do something with all the values you have parsed from the row
    }
    

提交回复
热议问题