Products

Solutions

Resources

Partners

Community

Blog

About

QA

Ideas Test

New Community Website

Ordinarily, you'd be at the right spot, but we've recently launched a brand new community website... For the community, by the community.

Yay... Take Me to the Community!

Welcome to the DNN Community Forums, your preferred source of online community support for all things related to DNN.
In order to participate you must be a registered DNNizen

HomeHomeArchived Discus...Archived Discus...Developing Under Previous Versions of .NETDeveloping Under Previous Versions of .NETASP.Net 2.0ASP.Net 2.0Gridview Custom Updating...Gridview Custom Updating...
Previous
 
Next
New Post
12/21/2007 1:12 PM
 

Friends,

I feel really stupid and frusterated on this one because I can't find any good material on the matter and I can't imagine that this isn't a common problem.

  1. I have created a GridView with and ObjectDataSource.
  2. I want to use inline editing.
  3. I do not want to show all of the fields.
  4. I want to automatically make the ModifiedOn field equal the date and time.

To do this, It's clear that I have to create or override the current updating events most likely RowUpdating. But I can't figure out how to do it while passing on the correct values. The NewValues collection is read only etc. etc.

Does ANYONE have some example code on how do to this? PLEASE?

Thanks in advance!

--Andrew

 
New Post
12/26/2007 4:11 PM
 

Maybe I'm not understanding what your trying to do but hopefully this helps…

I have not done with a objectdatasource before, but I do this all the time with a SQL data source. If you’re storing the ModifiedOn date in the database, as part of our data source update command, have it update the ModifiedDate with the current date. On each update of the gridview record, it should pull back the updated record with the newly modified ModifiedDate as well.

Below is a rough example of how to do this with a SQL data source and TSQL commands that I know works. One key here is the UpdateComand and the code of "sdtLastMod = GetDate() ", which keeps the modified date correct. On each update, the UPDATE query takes care of updating the last modified date, and after the update is complete, the grid reloads its values which contain the correct last modified date.

 <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString %>"
            SelectCommand="SELECT intRID2, intRID, strRelatedValue, sdtLastMod FROM tblRelated WHERE intRID = @intRID" DeleteCommand="DELETE FROM tblRelated WHERE (intRID2 = @intRID2)" UpdateCommand="UPDATE tblRelated SET intRID = @intRID , strRelatedValue = @strRelatedValue, sdtLastMod = GetDate() WHERE (intRID2 = @intRID2)">
            <SelectParameters>
                <asp:QueryStringParameter DefaultValue="-1" Name="intRID" QueryStringField="ID" Type="Int32" />
            </SelectParameters>
            <DeleteParameters>
                <asp:Parameter Name="intRID2" />
            </DeleteParameters>
            <UpdateParameters>
                <asp:Parameter Name="intRID" />
                <asp:Parameter Name="strRelatedValue" />
                <asp:Parameter Name="intRID2" />
            </UpdateParameters>
        </asp:SqlDataSource>

 

 <asp:GridView ID="GridView2" runat="server" SelectedIndex="0" AutoGenerateColumns="False" DataKeyNames="intRID2" AutoGenerateEditButton="true" DataSourceID="SqlDataSource1" AutoGenerateDeleteButton="True">
            <Columns>
                <asp:BoundField DataField="intRID2" HeaderText="intRID2" SortExpression="intRID2" />
                <asp:BoundField DataField="intRID" HeaderText="intRID" SortExpression="intRID" />
                <asp:BoundField DataField="sdtLastMod" HeaderText="sdtLastMod" SortExpression="sdtLastMod" />
                <asp:BoundField DataField="strRelatedValue" HeaderText="strRelatedValue" SortExpression="strRelatedValue" />
            </Columns>
        </asp:GridView>

 

 
Previous
 
Next
HomeHomeArchived Discus...Archived Discus...Developing Under Previous Versions of .NETDeveloping Under Previous Versions of .NETASP.Net 2.0ASP.Net 2.0Gridview Custom Updating...Gridview Custom Updating...


These Forums are dedicated to discussion of DNN Platform and Evoq Solutions.

For the benefit of the community and to protect the integrity of the ecosystem, please observe the following posting guidelines:

  1. No Advertising. This includes promotion of commercial and non-commercial products or services which are not directly related to DNN.
  2. No vendor trolling / poaching. If someone posts about a vendor issue, allow the vendor or other customers to respond. Any post that looks like trolling / poaching will be removed.
  3. Discussion or promotion of DNN Platform product releases under a different brand name are strictly prohibited.
  4. No Flaming or Trolling.
  5. No Profanity, Racism, or Prejudice.
  6. Site Moderators have the final word on approving / removing a thread or post or comment.
  7. English language posting only, please.
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out