I'm trying to pass a guid to the WHERE statement in a gridview. It works for the Select parameters section, but inserts a null value when I try to update the data.
<asp:SqlDataSource ID="SqlDataSource2" runat="server"
ConnectionString="<%$ ConnectionStrings:EDUFormConnectionString %>"
SelectCommand="SELECT OSSPERSON.PERSONID,OSSPERSON.FIRSTNAME, OSSPERSON.LASTNAME, OSSPERSON.AorC, OSSPERSON.AGE, OSSPERSON.GENDER FROM OSSPERSON INNER JOIN OSSREGPERSON ON OSSPERSON.PERSONID = OSSREGPERSON.PERSONID INNER JOIN OSSREG ON OSSREGPERSON.REGID = OSSREG.REGID WHERE (OSSREG.GenGuid = @guid)"
UpdateCommand="UPDATE dbo.OSSPERSON
SET OSSPERSON.Firstname = @FIRSTNAME
, OSSPERSON.Lastname=@LASTNAME
, OSSPERSON.AorC=@AorC
, OSSPERSON.Age=@AGE
, OSSPERSON.Gender = @GENDER
FROM EDUForm.dbo.OSSPERSON INNER JOIN EDUForm.dbo.OSSREGPERSON ON OSSPERSON.PERSONID = OSSREGPERSON.PERSONID
INNER JOIN EDUForm.dbo.OSSREG ON OSSREGPERSON.REGID = OSSREG.REGID WHERE
(OSSREG.PERSONID = @PERSONID)" onselecting="SqlDataSource2_Selecting">
<SelectParameters>
<asp:Parameter Name="guid" Type="String"/>
<%--<asp:SessionParameter Name="guid" SessionField="guid"
DefaultValue="" />--%>
</SelectParameters>
<UpdateParameters>
<asp:Parameter Name="PERSONID" Type="Int32" />
<asp:Parameter Name="FIRSTNAME" Type="String" />
<asp:Parameter Name="LASTNAME" Type="String" />
<asp:Parameter Name="AorC" Type="String" />
<asp:Parameter Name="AGE" Type="Int16" />
<asp:Parameter Name="GENDER" Type="String" />
<asp:Parameter Name="guid" Type="String"/>
</UpdateParameters>
</asp:SqlDataSource>
protected void SqlDataSource2_Selecting(object sender, SqlDataSourceSelectingEventArgs e)
{
if (guid != null)
{
e.Command.Parameters["@guid"].Value = guid;
}
}