Question : asp.net need help on setting color fro a gridview cell on added row

I am getting an error on the  server :

e.Row.RowType ...does not work here what should I do.
 
Compiler Error Message: BC30456: 'Row' is not a member of 'System.Web.UI.WebControls.GridViewCommandEventArgs'.

Source Error:

Line 268:    ' Checking if row type
Line 269:    
Line 270:        If e.Row.RowType = DataControlRowType.DataRow Then
Line 271:        
Line 272:        ' find the label control
 
Code Snippet:
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
Protected Sub uxItemDetailGrid_RowCommand(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewCommandEventArgs) Handles uxItemDetailGrid.RowCommand 
    
    ' We are checking against the "ADD" 
    
      If e.CommandName = "ADD" Then

        Dim strName As String = DirectCast(uxItemDetailGrid.FooterRow.FindControl("strName"), TextBox).Text 
        Dim strEmail As String = DirectCast(uxItemDetailGrid.FooterRow.FindControl("strEmail"), TextBox).Text
        Dim strRegistrationUserName As String = DirectCast(uxItemDetailGrid.FooterRow.FindControl("strRegistrationUserName"), TextBox).Text
        Dim strBadgeName As String = DirectCast(uxItemDetailGrid.FooterRow.FindControl("strBadgeName"), TextBox).Text
        Dim fltOrderAmount As String = DirectCast(uxItemDetailGrid.FooterRow.FindControl("fltOrderAmount"), TextBox).Text    
      
       if (strName = "" or strEmail = "" or fltOrderAmount = "") then 
          Bind()
       else
        Dim connectionString As String = ConfigurationManager.ConnectionStrings("SiteSqlServer").ConnectionString
    
        Dim myConnection As New SqlConnection(connectionString)
        Dim query As String = "INSERT INTO i2Integration_EventRegv45_Registration(intEventID,intRegistrationCount,strName,strEmail,fltOrderAmount,fltDiscountAmount,fltDiscountPercent,strPaymentMethodID,blnEmailSent,strRegistrationStatusID) SELECT e.intEventID,1,@strName,@strEmail,@fltOrderAmount,0,0,'Check',0,'cmp' FROM i2Integration_EventRegv45_Event e where (YEAR(e.dtmEvent) = '" + ddlYear.SelectedValue + "' AND MONTH(e.dtmEvent) = '" + ddlMth.SelectedValue + "') AND e.strTitle = '" + DroplistData.SelectedValue.Tostring + "' Order by e.dtmEvent"

         Dim myCommand As New SqlCommand(query, myConnection)

        'myCommand.Parameters.AddWithValue("@intEventID", intEventID)
        'myCommand.Parameters.AddWithValue("@dtmEvent", dtmEvent)
        'myCommand.Parameters.AddWithValue("@strTitle", strTitle)

        myCommand.Parameters.AddWithValue("@strName", strName)
        myCommand.Parameters.AddWithValue("@strEmail", strEmail)
        myCommand.Parameters.AddWithValue("@fltOrderAmount", fltOrderAmount)
        myConnection.Open()
        myCommand.ExecuteNonQuery()
        myConnection.Close() 
  
      ' Checking if row type 
        if e.Row.RowType = DataControlRowType.DataRow Then
        ' find the label control 
         Dim lblPaymentMethod As Label = TryCast(e.Row.FindControl(lblstrPaymentMethodID), Label)       
            ' get the cell where that label contains   
            Dim d As DataControlFieldCell = TryCast(lblPaymentMethod.Parent, DataControlFieldCell)           
            ' to change the backcolor 
            d.BackColor = System.Drawing.Color.Blue
        end if
    End If
   End Sub

Answer : asp.net need help on setting color fro a gridview cell on added row

I forgot to mention that e.row does not exist in the event args for the RowCommand event but does exist in the RowDataBound event

This may be the source of the confusion...
Random Solutions  
 
programming4us programming4us