Wednesday, October 1, 2008

Catch the Cell value in Row_Updating in Gridview

This for only in Bound fields: 

DataControlFieldCell cell = gvUser.Rows[e.RowIndex].Cells[1] as DataControlFieldCell;
        gvUser.Columns[1].ExtractValuesFromCell(e.NewValues, cell, DataControlRowState.Edit, true);
        foreach (string key in e.NewValues.Keys)
        {
            EditUserMail(e.NewValues[key].ToString());
        }

Inline:

  asp:BoundField DataField="Email" HeaderText="Email"

Where EditUserMail can be any function.





This is for Template fields:


TextBox txtDate = (TextBox)gvUser.Rows[e.RowIndex].FindControl("txtDate");
        EditApprovedDate(txtDate.Text);

 asp:TemplateField HeaderText="Approved Till"

                ItemTemplate
                    asp:Label ID="Label1" runat="server" Text='%# Eval("Comment") %
asp:Label

                
ItemTemplate

           
EditItemTemplate

           
asp:TextBox ID="txtDate" Text=
%#Eval("Comment") %
runat="server"


asp:TextBox

        
cc1:CalendarExtender ID="CalendarExtender1" runat="server" TargetControlID="txtDate"
                 Animated="true" PopupPosition="Right" FirstDayOfWeek="Monday"

          
cc1:CalendarExtender

              
           EditItemTemplate
            

asp:TemplateField
              
            
            


Where EditApprovedDate can be any Function.


Thanks,
Nitin Sharma