Mike C Mike C - 3 months ago 14
C# Question

Formview: How to set parameter for non-updated items

This is probably quite simple but I have not found anything in my readings. I am trying to update some records however the fields that I do not update are reverting to null and not the

Bind()
value. Because of that my update script is failing. What am I missing?

Here is the
<EditTemplate>


<EditItemTemplate>
<h2 class="col-md-12"><asp:Label ID="lbldocid" runat="server" Text=<%# Bind("docid") %> /> - <asp:Label ID="lblclient" runat="server" Text=<%# Bind("sName") %> /></h2>

<div class="left col-md-10">
<legend>Matter Info:</legend>
<div class="form-group"><asp:Label ID="Label1" runat="server" Text="Matter" AssociatedControlID="dcname"/>
<asp:TextBox ID="dcname" runat="server" CssClass="form-control" Text=<%# DataBinder.Eval(Container.DataItem,"sDocname") %> /></div>
</div>

<div class="left col-md-10">
<hr />
<div class="form-group">
<asp:Label ID="Label2" runat="server" Text="Notes/Comments" AssociatedControlID="dcnotes" /><br />
<asp:TextBox ID="dcnotes" runat="server" Rows="3" TextMode="MultiLine" Wrap="true" Text=<%# Bind("sdocdesc") %> />
</div>
</div>

<div class="left col-md-6 col-md-offset-5 txsmall">
<asp:Label ID="Label3" runat="server" Text="Filed: " Font-Bold="true" /><asp:Label ID="lblfiledate" runat="server" Text=<%# Bind("dtFiledate") %> CssClass="txsmall" Font-Italic="true" />
<asp:Label ID="Label4" runat="server" Text="Modified: " Font-Bold="true" /><asp:Label ID="lblmodify" runat="server" Text=<%# Bind("dtLastModified") + " - " + Bind("susermodified") %> CssClass="txsmall" Font-Italic="true"/>
</div>
<div class="clear-fix col-md-12">
<div class="form-group">
<asp:LinkButton runat="server" Text="Save" ID="SaveButton" CommandName="Update" CssClass="clear-fix btn btn-info" Enabled="false" />&nbsp;
<asp:LinkButton runat="server" Text="Cancel" ID="btnCancel" CommandName="Cancel" CssClass="clear-fix btn btn-info" />&nbsp;
</div>
</div>
</EditItemTemplate>


SQLDATASOURCE Updateparameters:

<UpdateParameters>
<asp:Parameter Name="DOCID" Type="String"></asp:Parameter>
<asp:Parameter Name="hClient" Type="Int32"></asp:Parameter>
<asp:Parameter Name="sDocName" Type="String" />
<asp:Parameter Name="sDocDesc" Type="String" />
<asp:Parameter Name="sUserModified" Type="String"></asp:Parameter>
<asp:Parameter Name="type" Type="Int32" DefaultValue="0"></asp:Parameter>
</UpdateParameters>

Answer

Changed the types to SqlDBType and that appears to have fixed the issue.

Comments