I have a simple gridview (well it is now) it populates, I can edit it. but when it comes to updating I just cant get it to work.
The following code creates a gridview which searches for users whose name starts with a "c" (Thats part of my filtering I stripped out)
The problem is when I click the update button it won't update. The Stored procedure gets called but all parameters passed to it are null. therefore the database is not updated.
I know its a simple problem with a simple solution but I just can't see it.
I tried using ExtractValuesFromCell
within the onupdating event and still only got nulls. I had to add the CausesValidation="false"
because without it the update events were not even called.
Any and all help is appreciated
<asp:GridView ID="GridView1" runat="server" AllowPaging="True"
AutoGenerateColumns="False" DataSourceID="SqlDataSource3"
DataKeyNames="UserId">
<Columns>
<asp:CommandField ShowEditButton="True" CausesValidation="false" />
<asp:BoundField DataField="UserName" HeaderText="UserName"
SortExpression="UserName" />
<asp:BoundField DataField="MobileAlias" HeaderText="MobileAlias"
SortExpression="MobileAlias" />
<asp:BoundField DataField="DistrictId" HeaderText="DistrictId"
SortExpression="DistrictId" />
<asp:BoundField ReadOnly="true" DataField="UserId" HeaderText="UserId"
SortExpression="UserId" />
</Columns>
</asp:GridView> <asp:SqlDataSource ID="SqlDataSource3" runat="server"
ConnectionString="<%$ ConnectionStrings:REMConnectionString_development_dev %>"
SelectCommand="LoadUser" SelectCommandType="StoredProcedure"
UpdateCommand="UpdateUser" UpdateCommandType="StoredProcedure"
onupdating="SqlDataSource3_Updating">
<SelectParameters>
<asp:Parameter DefaultValue="c" Name="UserName" Type="String" />
</SelectParameters>
<UpdateParameters>
<asp:Parameter Name="UserId" Type="String" />
<asp:Parameter Name="DistrictID" Type="Int32" />
<asp:Parameter Name="UserName" Type="String" />
<asp:Parameter Name="MobileAlias" Type="String" />
</UpdateParameters>
</asp:SqlDataSource>
the only code in the codebehind is
protected void SqlDataSource3_Updating(object sender, SqlDataSourceCommandEventArgs e)
{
}
It is there so I can drop in a breakpoint and inspect the parameters, which are all there but with null values