I'm only updating int and string values...
Here's a snippet of my code:
[ASPX page]:
<asp:GridView ID="gridViewNews" runat="server"
AutoGenerateColumns="False" DataSourceID="ObjectDataSource1"
DataKeyNames="cid,rid">
<Columns>
<asp:CommandField ShowEditButton="True" >
</asp:CommandField>
<asp:BoundField DataField="cid" HeaderText="CID" ReadOnly="True"
SortExpression="cid" />
<asp:BoundField DataField="rid" HeaderText="RID" ReadOnly="True"
SortExpression="rid" />
<asp:BoundField DataField="controlvocabulary"
HeaderText="Thesaurus" ReadOnly="False"
SortExpression="controlvocabulary" HtmlEncode="false" />
<asp:BoundField DataField="title" HeaderText="Rx Title"
ReadOnly="True" SortExpression="title" />
</Columns>
</asp:GridView>
<asp:ObjectDataSource ID="ObjectDataSource1" runat="server"
OldValuesParameterFormatString="original_{}"
SelectMethod="getInvalidItemByNews" UpdateMethod="editNews"
TypeName="Rx">
<UpdateParameters>
<asp
arameter Name="original_cid" Type="Int32" />
<asp
arameter Name="original_rid" Type="Int32" />
<asp
arameter Name="controlvocabulary" Type="String" />
</UpdateParameters>
</asp:ObjectDataSource>
[CLASS page with UPDATE method]:
public static void editNews(int original_cid, int original_rid, string
controlvocabulary, string title) {
using (SqlConnection connection = new
SqlConnection(ConfigurationManager.ConnectionStrings["OFHC-RX_RxConnectionString"].ConnectionString))
{
using (SqlCommand command = new SqlCommand("lex_EditNews",
connection)) {
command.CommandType = CommandType.StoredProcedure;
command.Parameters.Add("@contentid", SqlDbType.Int).Value =
original_cid;
command.Parameters.Add("@revisionid", SqlDbType.Int).Value
= original_rid;
command.Parameters.Add("@controledvocabvalue",
SqlDbType.NVarChar, 1000).Value = controlvocabulary;
int result = 0;
connection.Open();
result = command.ExecuteNonQuery();
connection.Close();
}
}
}