Link to home
Start Free TrialLog in
Avatar of mconti41
mconti41

asked on

Handles clause requires a withevents variable defined within the container type or one of its base types

I am trying to accomplish a simple SQL Insert to DB2 db table based on a button click event. I am including code for an experts review. I am desperate to resolve.
Aspx:
<asp:SqlDataSource ID="SqlDataSourceDependent" runat="server" 
              ConnectionString="<%$ ConnectionStrings:ConnectionString %>" 
              ProviderName="<%$ ConnectionStrings:ConnectionString.ProviderName %>" 
                      InsertCommand="INSERT INTO ENROLL.ENR02(E2GRP, E2SSN, E2DSSN, E2NAML, E2NAMF, E2NAMM, E2DOB, E2EFF, E2TRM, E2SEXC, E2RELC, E2QEVN, E2OTHI, E2FTS, E2FTSE, E2FTST) VALUES (,,,,,,,,,,,,,,,)">
               <InsertParameters>
                   <asp:QueryStringParameter Name="newparameter" QueryStringField="grpId" />
                   <asp:QueryStringParameter Name="newparameter" QueryStringField="memId" />
               </InsertParameters>
               
        </asp:SqlDataSource>  
        
         <table align="left"bgcolor="ffff99" width="75%">
               <tr bgcolor="ffff99">
				 <td colspan="4" align="center"><asp:Button ID="ButtonAddDepend" 
                         onclick="Dependent_Inserted" runat="server" Text="Add Dependent" 
                        Height="25px" Width="102px" 
                        /></td>
                        
			    </tr>
		</table>
 
Code Behind:
Protected Sub Dependent_Inserted(ByVal sender As Object, ByVal e As System.EventArgs) Handles Dependent.Inserted
 
        SqlDataSourceDependent.Insert()
 
    End Sub

Open in new window

Avatar of abel
abel
Flag of Netherlands image

How does your code behind look like?
ASKER CERTIFIED SOLUTION
Avatar of abel
abel
Flag of Netherlands image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of mconti41
mconti41

ASKER

This is my code behind logic :

Protected Sub Dependent_Inserted(ByVal sender As Object, ByVal e As System.EventArgs) Handles Dependent.Inserted
 
        SqlDataSourceDependent.Insert()
 
    End Sub
Abel, I am not sure how to write a handler and would apppreciate your advise on this...