This is a migrated thread and some comments may be shown as answers.

manage values when update my grid

3 Answers 32 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Hamza
Top achievements
Rank 1
Hamza asked on 15 Sep 2011, 06:36 PM
Hi all :)


I have a grid that contain date, time, user ID and other columns 

I don't want to update date, time, ID manually, can I make the system using some code inter the system date and time ?

and take the ID from a session ?

please help me with this 



thank you all :)

3 Answers, 1 is accepted

Sort by
0
Jayesh Goyani
Top achievements
Rank 2
answered on 15 Sep 2011, 06:49 PM
Hello,

please provide your code so i can update your code and give back to you.

Thanks,
Jayesh Goyani
0
Hamza
Top achievements
Rank 1
answered on 15 Sep 2011, 07:16 PM
Hello

I have this 

<%@ Control Language="C#" AutoEventWireup="true" CodeFile="AboutUs.ascx.cs" Inherits="HTKfjksh7869435fds435_ljagut32542GSDFG_lgjdfsh32452GR235GGOJA324_Contros_AboutUs" %>
<telerik:RadScriptManager ID="RadScriptManager1" Runat="server">
</telerik:RadScriptManager>
<telerik:RadAjaxLoadingPanel ID="RadAjaxLoadingPanel1" Runat="server"
    Skin="Default">
</telerik:RadAjaxLoadingPanel>
<telerik:RadAjaxPanel ID="RadAjaxPanel1" runat="server" height="200px"
    HorizontalAlign="NotSet" LoadingPanelID="RadAjaxLoadingPanel1" width="300px">
    <telerik:RadGrid ID="RadGrid1" runat="server" AllowAutomaticDeletes="True"
        AllowAutomaticInserts="True" AllowAutomaticUpdates="True" AllowPaging="True"
        AutoGenerateColumns="False" AutoGenerateDeleteColumn="True"
        AutoGenerateEditColumn="True" CellSpacing="0" DataSourceID="SqlDataSource1"
        GridLines="None" ShowFooter="True" Skin="Black">
        <MasterTableView DataKeyNames="AboutUs_Language" DataSourceID="SqlDataSource1">
            <CommandItemSettings ExportToPdfText="Export to PDF" />
            <RowIndicatorColumn FilterControlAltText="Filter RowIndicator column">
                <HeaderStyle Width="20px" />
            </RowIndicatorColumn>
            <ExpandCollapseColumn FilterControlAltText="Filter ExpandColumn column">
                <HeaderStyle Width="20px" />
            </ExpandCollapseColumn>
            <Columns>
                <telerik:GridBoundColumn DataField="AboutUs_Language"
                    FilterControlAltText="Filter AboutUs_Language column" HeaderText="Language"
                    ReadOnly="True" SortExpression="AboutUs_Language" UniqueName="AboutUs_Language">
                </telerik:GridBoundColumn>
                <telerik:GridHTMLEditorColumn DataField="AboutUs_Text"
                    FilterControlAltText="Filter AboutUs_Text column" HeaderText="Text"
                    SortExpression="AboutUs_Text" UniqueName="AboutUs_Text">
                </telerik:GridHTMLEditorColumn>
                 
                <telerik:GridBoundColumn DataField="AboutUs_LastModifierID"
                    DataType="System.Int32"
                    FilterControlAltText="Filter AboutUs_LastModifierID column"
                    ForceExtractValue="InEditMode" HeaderText="AboutUs_LastModifierID"
                    SortExpression="AboutUs_LastModifierID" UniqueName="AboutUs_LastModifierID">
                </telerik:GridBoundColumn>
 
                <telerik:GridBoundColumn DataField="AboutUs_ModifierIP"
                    FilterControlAltText="Filter AboutUs_ModifierIP column"
                    HeaderText="AboutUs_ModifierIP" ReadOnly="True"
                    SortExpression="AboutUs_ModifierIP" UniqueName="AboutUs_ModifierIP">
                </telerik:GridBoundColumn>
 
                <telerik:GridDateTimeColumn DataField="AboutUs_DateOfLastModification"
                    DataType="System.DateTime"
                    FilterControlAltText="Filter AboutUs_DateOfLastModification column"
                    ForceExtractValue="InEditMode" HeaderText="Date" ReadOnly="True"
                    SortExpression="AboutUs_DateOfLastModification"
                    UniqueName="AboutUs_DateOfLastModification">
                </telerik:GridDateTimeColumn>
 
                <telerik:GridDateTimeColumn DataField="AboutUs_TimeOfLastModification"
                    DataType="System.TimeSpan" FilterControlAltText="Filter column column"
                    ForceExtractValue="InEditMode" HeaderText="AboutUs_TimeOfLastModification"
                    ReadOnly="True" SortExpression="AboutUs_TimeOfLastModification"
                    UniqueName="column">
                </telerik:GridDateTimeColumn>
 
            </Columns>
            <EditFormSettings>
                <EditColumn FilterControlAltText="Filter EditCommandColumn column">
                </EditColumn>
            </EditFormSettings>
        </MasterTableView>
        <FilterMenu EnableImageSprites="False">
        </FilterMenu>
        <HeaderContextMenu CssClass="GridContextMenu GridContextMenu_Black">
        </HeaderContextMenu>
    </telerik:RadGrid>
</telerik:RadAjaxPanel>
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
    ConflictDetection="CompareAllValues"
    ConnectionString="<%$ ConnectionStrings:MSAGroup_Darfas.comConnectionString %>"
    DeleteCommand="DELETE FROM [AboutUs] WHERE [AboutUs_Language] = @original_AboutUs_Language AND [AboutUs_Text] = @original_AboutUs_Text AND (([AboutUs_DateOfLastModification] = @original_AboutUs_DateOfLastModification) OR ([AboutUs_DateOfLastModification] IS NULL AND @original_AboutUs_DateOfLastModification IS NULL)) AND (([AboutUs_TimeOfLastModification] = @original_AboutUs_TimeOfLastModification) OR ([AboutUs_TimeOfLastModification] IS NULL AND @original_AboutUs_TimeOfLastModification IS NULL)) AND (([AboutUs_LastModifierID] = @original_AboutUs_LastModifierID) OR ([AboutUs_LastModifierID] IS NULL AND @original_AboutUs_LastModifierID IS NULL)) AND (([AboutUs_ModifierIP] = @original_AboutUs_ModifierIP) OR ([AboutUs_ModifierIP] IS NULL AND @original_AboutUs_ModifierIP IS NULL))"
    InsertCommand="INSERT INTO [AboutUs] ([AboutUs_Text], [AboutUs_DateOfLastModification], [AboutUs_TimeOfLastModification], [AboutUs_LastModifierID], [AboutUs_ModifierIP], [AboutUs_Language]) VALUES (@AboutUs_Text, @AboutUs_DateOfLastModification, @AboutUs_TimeOfLastModification, @AboutUs_LastModifierID, @AboutUs_ModifierIP, @AboutUs_Language)"
    OldValuesParameterFormatString="original_{0}"
    SelectCommand="SELECT [AboutUs_Text], [AboutUs_DateOfLastModification], [AboutUs_TimeOfLastModification], [AboutUs_LastModifierID], [AboutUs_ModifierIP], [AboutUs_Language] FROM [AboutUs]"
    UpdateCommand="UPDATE [AboutUs] SET [AboutUs_Text] = @AboutUs_Text, [AboutUs_DateOfLastModification] = @AboutUs_DateOfLastModification, [AboutUs_TimeOfLastModification] = @AboutUs_TimeOfLastModification, [AboutUs_LastModifierID] = @AboutUs_LastModifierID, [AboutUs_ModifierIP] = @AboutUs_ModifierIP WHERE [AboutUs_Language] = @original_AboutUs_Language AND [AboutUs_Text] = @original_AboutUs_Text AND (([AboutUs_DateOfLastModification] = @original_AboutUs_DateOfLastModification) OR ([AboutUs_DateOfLastModification] IS NULL AND @original_AboutUs_DateOfLastModification IS NULL)) AND (([AboutUs_TimeOfLastModification] = @original_AboutUs_TimeOfLastModification) OR ([AboutUs_TimeOfLastModification] IS NULL AND @original_AboutUs_TimeOfLastModification IS NULL)) AND (([AboutUs_LastModifierID] = @original_AboutUs_LastModifierID) OR ([AboutUs_LastModifierID] IS NULL AND @original_AboutUs_LastModifierID IS NULL)) AND (([AboutUs_ModifierIP] = @original_AboutUs_ModifierIP) OR ([AboutUs_ModifierIP] IS NULL AND @original_AboutUs_ModifierIP IS NULL))">
    <DeleteParameters>
        <asp:Parameter Name="original_AboutUs_Language" Type="String" />
        <asp:Parameter Name="original_AboutUs_Text" Type="String" />
        <asp:Parameter DbType="Date" Name="original_AboutUs_DateOfLastModification" />
        <asp:Parameter DbType="Time" Name="original_AboutUs_TimeOfLastModification" />
        <asp:Parameter Name="original_AboutUs_LastModifierID" Type="Int32" />
        <asp:Parameter Name="original_AboutUs_ModifierIP" Type="String" />
    </DeleteParameters>
    <InsertParameters>
        <asp:Parameter Name="AboutUs_Text" Type="String" />
        <asp:Parameter DbType="Date" Name="AboutUs_DateOfLastModification" />
        <asp:Parameter DbType="Time" Name="AboutUs_TimeOfLastModification" />
        <asp:Parameter Name="AboutUs_LastModifierID" Type="Int32" />
        <asp:Parameter Name="AboutUs_ModifierIP" Type="String" />
        <asp:Parameter Name="AboutUs_Language" Type="String" />
    </InsertParameters>
    <UpdateParameters>
        <asp:Parameter Name="AboutUs_Text" Type="String" />
        <asp:Parameter DbType="Date" Name="AboutUs_DateOfLastModification" />
        <asp:Parameter DbType="Time" Name="AboutUs_TimeOfLastModification" />
        <asp:Parameter Name="AboutUs_LastModifierID" Type="Int32" />
        <asp:Parameter Name="AboutUs_ModifierIP" Type="String" />
        <asp:Parameter Name="original_AboutUs_Language" Type="String" />
        <asp:Parameter Name="original_AboutUs_Text" Type="String" />
        <asp:Parameter DbType="Date" Name="original_AboutUs_DateOfLastModification" />
        <asp:Parameter DbType="Time" Name="original_AboutUs_TimeOfLastModification" />
        <asp:Parameter Name="original_AboutUs_LastModifierID" Type="Int32" />
        <asp:Parameter Name="original_AboutUs_ModifierIP" Type="String" />
    </UpdateParameters>
</asp:SqlDataSource>


and I want to inter date and time from the system,

                
<telerik:GridDateTimeColumn DataField="AboutUs_DateOfLastModification"
                    DataType="System.DateTime"
                    FilterControlAltText="Filter AboutUs_DateOfLastModification column"
                    ForceExtractValue="InEditMode" HeaderText="Date" ReadOnly="True"
                    SortExpression="AboutUs_DateOfLastModification"
                    UniqueName="AboutUs_DateOfLastModification">
                </telerik:GridDateTimeColumn>
  
                <telerik:GridDateTimeColumn DataField="AboutUs_TimeOfLastModification"
                    DataType="System.TimeSpan" FilterControlAltText="Filter column column"
                    ForceExtractValue="InEditMode" HeaderText="AboutUs_TimeOfLastModification"
                    ReadOnly="True" SortExpression="AboutUs_TimeOfLastModification"
                    UniqueName="column">
                </telerik:GridDateTimeColumn>


 userID from some session,


<telerik:GridBoundColumn DataField="AboutUs_LastModifierID"
    DataType="System.Int32"
    FilterControlAltText="Filter AboutUs_LastModifierID column"
    ForceExtractValue="InEditMode" HeaderText="AboutUs_LastModifierID"
    SortExpression="AboutUs_LastModifierID" UniqueName="AboutUs_LastModifierID">
</telerik:GridBoundColumn>



 IP from a function


<telerik:GridBoundColumn DataField="AboutUs_ModifierIP"
    FilterControlAltText="Filter AboutUs_ModifierIP column"
    HeaderText="AboutUs_ModifierIP" ReadOnly="True"
    SortExpression="AboutUs_ModifierIP" UniqueName="AboutUs_ModifierIP">
</telerik:GridBoundColumn>







and I wrote no code in C# yet :\


thank you so much :)




0
Hamza
Top achievements
Rank 1
answered on 16 Sep 2011, 02:05 PM
thank you my friend, I did it with some tries ;)

thank you so much
Tags
Grid
Asked by
Hamza
Top achievements
Rank 1
Answers by
Jayesh Goyani
Top achievements
Rank 2
Hamza
Top achievements
Rank 1
Share this question
or