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

Some fields in detail grid not updating

6 Answers 102 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Reda
Top achievements
Rank 1
Reda asked on 26 Sep 2008, 08:41 PM
Hello everyone, I've ha this problem for a few hrs now and still can't resolve it. I have a Master - Detail grid and one particular field in the detail grid does not get updated whereas the rest all get updated correctly. The field that is not gettting updated is the "PermissionID" field found in the 2nd level detail grid:

Here is the aspx code:

<telerik:RadGrid ID="gridCompanies" runat="server" AllowFilteringByColumn="True"

        AllowPaging="True" AllowSorting="True" DataSourceID="dsCompanies" GridLines="None"

        ShowGroupPanel="True" Skin="Office2007" ShowStatusBar="True"

        AllowAutomaticUpdates="True" AllowAutomaticInserts="True" AllowAutomaticDeletes="True">

       

        <AlternatingItemStyle BackColor="#E6E6E6" Font-Bold="False" Font-Italic="False"

        Font-Overline="False" Font-Strikeout="False" Font-Underline="False"

        Wrap="True" />

       

        <PagerStyle Mode="NextPrevAndNumeric" />

   

        <MasterTableView Name="Master" AllowAutomaticUpdates="True" AllowAutomaticInserts="True" CommandItemDisplay="Top" AutoGenerateColumns="False" DataKeyNames="CompanyID" DataSourceID="dsCompanies">

           

            <RowIndicatorColumn>

            <HeaderStyle Width="20px"></HeaderStyle>

            </RowIndicatorColumn>

 

            <DetailTables>

                <telerik:GridTableView Name="Detail" CommandItemDisplay="Top" DataKeyNames="CompanyUserID"

                    DataSourceID="dsCompanyUsers" AllowPaging="true" AllowSorting="true"

                    AllowFilteringByColumn="False" AutoGenerateColumns="false" Width="100%"

                    AllowAutomaticDeletes="True" AllowAutomaticInserts="False" AllowAutomaticUpdates="True">

                    <RowIndicatorColumn>

                        <HeaderStyle Width="20px" />

                    </RowIndicatorColumn>

                    <ParentTableRelation>

                        <telerik:GridRelationFields DetailKeyField="CompanyUserID"

                            MasterKeyField="CompanyUserID" />

                    </ParentTableRelation>

                    <ExpandCollapseColumn>

                        <HeaderStyle Width="20px" />

                    </ExpandCollapseColumn>

 

                    <Columns>

                        <telerik:GridEditCommandColumn UniqueName="EditCommandColumn2">

                            <HeaderStyle Width="3%"></HeaderStyle>

                            <ItemStyle Width="3%"></ItemStyle>

                        </telerik:GridEditCommandColumn>

                        <telerik:GridBoundColumn DataField="CompanyID" DataType="System.Int32"

                            HeaderText="CompanyID" Display="false" ReadOnly="True" SortExpression="CompanyID" UniqueName="CompanyID">

                        </telerik:GridBoundColumn>

                        <telerik:GridBoundColumn DataField="CompanyUserID" HeaderText="CompanyUserID"

                            SortExpression="CompanyUserID" Display="false" ReadOnly="True" UniqueName="CompanyUserID" DataType="System.Int32">

                        </telerik:GridBoundColumn>

                        <telerik:GridBoundColumn DataField="UserID" HeaderText="UserID"

                            SortExpression="UserID" UniqueName="UserID" Display="False" ReadOnly="True" DataType="System.Int32">

                        </telerik:GridBoundColumn>

                        <telerik:GridBoundColumn DataField="UserPermissionID" HeaderText="UserPermissionID"

                            SortExpression="UserPermissionID" UniqueName="UserPermissionID" Display="False" ReadOnly="True" DataType="System.Int32">

                        </telerik:GridBoundColumn>

                        <telerik:GridBoundColumn DataField="CompanyUserFName" HeaderText="First Name"

                            SortExpression="CompanyUserFName" UniqueName="CompanyUserFName">

                        </telerik:GridBoundColumn>

                        <telerik:GridBoundColumn DataField="CompanyUserLName" HeaderText="Last Name"

                            SortExpression="CompanyUserLName" UniqueName="CompanyUserLName">

                        </telerik:GridBoundColumn>

                        <telerik:GridBoundColumn DataField="CompanyUserTitle"

                            HeaderText="Title" SortExpression="CompanyUserTitle"

                            UniqueName="CompanyUserTitle">

                        </telerik:GridBoundColumn>

                        <telerik:GridBoundColumn DataField="CompanyUserEmail" HeaderText="Email"

                            SortExpression="CompanyUserEmail" UniqueName="CompanyUserEmail">

                        </telerik:GridBoundColumn>

                        <telerik:GridBoundColumn DataField="CompanyUserTel"

                            HeaderText="Tel." SortExpression="CompanyUserTel"

                            UniqueName="CompanyUserTel">

                        </telerik:GridBoundColumn>

                        <telerik:GridBoundColumn DataField="CompanyUserTelExt" HeaderText="Ext."

                            SortExpression="CompanyUserTelExt" UniqueName="CompanyUserTelExt">

                        </telerik:GridBoundColumn>

                        <telerik:GridBoundColumn DataField="CompanyUserCell" HeaderText="Cell"

                            SortExpression="CompanyUserCell" UniqueName="CompanyUserCell">

                        </telerik:GridBoundColumn>

                        <telerik:GridDropDownColumn DataField="PermissionID" DataSourceID="dsCompanyUsersPerms"

                            HeaderText="Permission" ListTextField="PermissionName" ListValueField="PermissionID"

                            UniqueName="PermissionID">

                        </telerik:GridDropDownColumn>

                        <telerik:GridCheckBoxColumn DataField="UserActive" HeaderText="Active"

                            SortExpression="UserActive" UniqueName="UserActive">

                            <HeaderStyle Width="5%"></HeaderStyle>

                            <ItemStyle Width="5%"></ItemStyle>

                        </telerik:GridCheckBoxColumn>

                    </Columns>

                </telerik:GridTableView>

            </DetailTables>

 

            <ExpandCollapseColumn>

            <HeaderStyle Width="20px"></HeaderStyle>

            </ExpandCollapseColumn>

           

            <Columns>

                <telerik:GridEditCommandColumn UniqueName="EditCommandColumn">

                    <HeaderStyle Width="3%"></HeaderStyle>

                    <ItemStyle Width="3%"></ItemStyle>

                </telerik:GridEditCommandColumn>

                <telerik:GridBoundColumn DataField="CompanyID" DataType="System.Int32"

                    HeaderText="CompanyID" ReadOnly="True" SortExpression="CompanyID"

                    UniqueName="CompanyID" Display="false">

                </telerik:GridBoundColumn>

                <telerik:GridDropDownColumn DataField="CountryID" DataSourceID="dsCountry"

                    HeaderText="Country" ListTextField="CountryName" ListValueField="CountryID"

                    UniqueName="CountryID">

                </telerik:GridDropDownColumn>

                <telerik:GridDropDownColumn DataField="ProvinceID" DataSourceID="dsProvince"

                    HeaderText="Province" ListTextField="ProvinceName" ListValueField="ProvinceID"

                    UniqueName="ProvinceID">

                </telerik:GridDropDownColumn>

                <telerik:GridBoundColumn DataField="CompanyName" HeaderText="Name"

                    SortExpression="CompanyName" UniqueName="CompanyName">

                </telerik:GridBoundColumn>

                <telerik:GridBoundColumn DataField="CompanyAddress" HeaderText="Address"

                    SortExpression="CompanyAddress" UniqueName="CompanyAddress">

                </telerik:GridBoundColumn>

                <telerik:GridBoundColumn DataField="CompanyCity" HeaderText="City"

                    SortExpression="CompanyCity" UniqueName="CompanyCity">

                </telerik:GridBoundColumn>

                <telerik:GridBoundColumn DataField="CompanyTel" HeaderText="Tel"

                    SortExpression="CompanyTel" UniqueName="CompanyTel">

                </telerik:GridBoundColumn>

                <telerik:GridBoundColumn DataField="CompanyTelAreaCode"

                    HeaderText="Tel Area Code" SortExpression="CompanyTelAreaCode"

                    UniqueName="CompanyTelAreaCode">

                </telerik:GridBoundColumn>

                <telerik:GridBoundColumn DataField="CompanyFax" HeaderText="Fax"

                    SortExpression="CompanyFax" UniqueName="CompanyFax">

                </telerik:GridBoundColumn>

                <telerik:GridBoundColumn DataField="CompanyFaxAreaCode"

                    HeaderText="Fax Area Code" SortExpression="CompanyFaxAreaCode"

                    UniqueName="CompanyFaxAreaCode">

                </telerik:GridBoundColumn>

                <telerik:GridBoundColumn DataField="CompanyDomain" HeaderText="Domain"

                    SortExpression="CompanyDomain" UniqueName="CompanyDomain">

                </telerik:GridBoundColumn>

            </Columns>

 

            <EditFormSettings>

            <EditColumn UniqueName="EditCommandColumn1"></EditColumn>

            </EditFormSettings>

 

            <PagerStyle Mode="NextPrevAndNumeric" />

       

        </MasterTableView>

 

        <ClientSettings AllowDragToGroup="True">

        </ClientSettings>

 

        <FilterMenu EnableTheming="True" Skin="Office2007">

        <CollapseAnimation Type="OutQuint" Duration="200"></CollapseAnimation>

        </FilterMenu>

       

    </telerik:RadGrid>

   

    <asp:SqlDataSource ID="dsCompanies" runat="server"

        ConnectionString="<%$ ConnectionStrings:VentrolSecurityConnectionString %>"

        InsertCommand="spCreateCompany" InsertCommandType="StoredProcedure"

        SelectCommand="spGetCompanies" SelectCommandType="StoredProcedure"

        UpdateCommand="spUpdateCompany" UpdateCommandType="StoredProcedure">

        <UpdateParameters>

            <asp:Parameter Name="CompanyID" Type="Int32" />

            <asp:Parameter Name="CountryID" Type="Int32" />

            <asp:Parameter Name="ProvinceID" Type="Int32" />

            <asp:Parameter Name="CompanyName" Type="String" ConvertEmptyStringToNull="true" />

            <asp:Parameter Name="CompanyAddress" Type="String" ConvertEmptyStringToNull="true" />

            <asp:Parameter Name="CompanyCity" Type="String" ConvertEmptyStringToNull="true" />

            <asp:Parameter Name="CompanyTel" Type="String" ConvertEmptyStringToNull="true" />

            <asp:Parameter Name="CompanyTelAreaCode" Type="String" ConvertEmptyStringToNull="true" />

            <asp:Parameter Name="CompanyFax" Type="String" ConvertEmptyStringToNull="true" />

            <asp:Parameter Name="CompanyFaxAreaCode" Type="String" ConvertEmptyStringToNull="true" />

            <asp:Parameter Name="CompanyDomain" Type="String" ConvertEmptyStringToNull="true" />

        </UpdateParameters>

        <InsertParameters>

            <asp:Parameter Name="CountryID" Type="Int32" />

            <asp:Parameter Name="ProvinceID" Type="Int32" />

            <asp:Parameter Name="CompanyName" Type="String" ConvertEmptyStringToNull="true" />

            <asp:Parameter Name="CompanyAddress" Type="String" ConvertEmptyStringToNull="true" />

            <asp:Parameter Name="CompanyCity" Type="String" ConvertEmptyStringToNull="true" />

            <asp:Parameter Name="CompanyTel" Type="String" ConvertEmptyStringToNull="true" />

            <asp:Parameter Name="CompanyTelAreaCode" Type="String" ConvertEmptyStringToNull="true" />

            <asp:Parameter Name="CompanyFax" Type="String" ConvertEmptyStringToNull="true" />

            <asp:Parameter Name="CompanyFaxAreaCode" Type="String" ConvertEmptyStringToNull="true" />

            <asp:Parameter Name="CompanyDomain" Type="String" ConvertEmptyStringToNull="true" />

        </InsertParameters>

    </asp:SqlDataSource>

   

    <asp:SqlDataSource ID="dsCompanyUsers" runat="server"

        ConnectionString="<%$ ConnectionStrings:VentrolSecurityConnectionString %>"

        SelectCommand="spGetCompanyUsers" SelectCommandType="StoredProcedure"

        UpdateCommand="spUpdateCompanyUser" UpdateCommandType="StoredProcedure">

        <SelectParameters>

            <asp:SessionParameter Name="CompanyID" SessionField="CompanyID" Type="Int32" />

        </SelectParameters>

        <UpdateParameters>

            <asp:Parameter Name="CompanyID" Type="Int32" />

            <asp:Parameter Name="UserID" Type="Int32" />

            <asp:Parameter Name="UserPermissionID" Type="Int32" />

            <asp:Parameter Name="CompanyUserID" Type="Int32" />

            <asp:Parameter Name="CompanyUserFName" Type="String" ConvertEmptyStringToNull="true" />

            <asp:Parameter Name="CompanyUserLName" Type="String" ConvertEmptyStringToNull="true" />

            <asp:Parameter Name="CompanyUserTitle" Type="String" ConvertEmptyStringToNull="true" />

            <asp:Parameter Name="CompanyUserEmail" Type="String" ConvertEmptyStringToNull="true" />

            <asp:Parameter Name="CompanyUserTel" Type="String" ConvertEmptyStringToNull="true" />

            <asp:Parameter Name="CompanyUserTelExt" Type="String" ConvertEmptyStringToNull="true" />

            <asp:Parameter Name="CompanyUserCell" Type="String" ConvertEmptyStringToNull="true" />

            <asp:Parameter Name="PermissionID" Type="Int32" />

            <asp:Parameter Name="UserActive" Type="Boolean" />

        </UpdateParameters>

    </asp:SqlDataSource>

   

    <asp:SqlDataSource ID="dsCompanyUsersPerms" runat="server"

        ConnectionString="<%$ ConnectionStrings:VentrolSecurityConnectionString %>"

        SelectCommand="spGetCompanyUsersPerms" SelectCommandType="StoredProcedure">

    </asp:SqlDataSource>

   

    <asp:SqlDataSource ID="dsProvince" runat="server"

        ConnectionString="<%$ ConnectionStrings:VentrolSecurityConnectionString %>"

        SelectCommand="spGetAllProvinces" SelectCommandType="StoredProcedure">

    </asp:SqlDataSource>

    <asp:SqlDataSource ID="dsCountry" runat="server"

        ConnectionString="<%$ ConnectionStrings:VentrolSecurityConnectionString %>"

        SelectCommand="spGetCountries" SelectCommandType="StoredProcedure">

    </asp:SqlDataSource>

    

    <telerik:RadAjaxManagerProxy ID="ajmProxy" runat="server" >

        <AjaxSettings>

            <telerik:AjaxSetting AjaxControlID="gridCompanies">

                <UpdatedControls>

                    <telerik:AjaxUpdatedControl ControlID="gridCompanies" />

                </UpdatedControls>

            </telerik:AjaxSetting>

        </AjaxSettings>

    </telerik:RadAjaxManagerProxy>

Here are the stored procedures for the detail grid:

ALTER

PROCEDURE [dbo].[spUpdateCompanyUser]

-- Add the parameters for the stored procedure here
@CompanyID int,
@UserID int,
@UserPermissionID int,
@CompanyUserID int,
@CompanyUserFName nvarchar(50),
@CompanyUserLName nvarchar(50),
@CompanyUserTitle nvarchar(50),
@CompanyUserEmail nvarchar(50),
@CompanyUserTel nvarchar(50),
@CompanyUserTelExt nvarchar(50),
@CompanyUserCell nvarchar(50),
@PermissionID int,
@UserActive bit
AS
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;

-- Insert statements for procedure here
-- Update Company User
UPDATE tbl_secure_Company_User
SET CompanyUserFName = @CompanyUserFName,
CompanyUserLName = @CompanyUserLName,
CompanyUserTitle = @CompanyUserTitle,
CompanyUserEmail = @CompanyUserEmail,
CompanyUserTel = @CompanyUserTel,
CompanyUserTelExt = @CompanyUserTelExt,
CompanyUserCell = @CompanyUserCell
WHERE CompanyUserID = @CompanyUserID

-- Update Company User Permission
EXEC spUpdateUserPerm @UserPermissionID,@PermissionID
END

------------------------------------------------------------

ALTER

PROCEDURE [dbo].[spUpdateUserPerm] -- Add the parameters for the stored procedure here
@UserPermissionID int,
@PermissionID int
AS
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;

-- Insert statements for procedure here
UPDATE tbl_secure_User_Permission
SET PermissionID = @PermissionID
WHERE UserPermissionID = @UserPermissionID
END

When I execute the stored procedures from within SQL management studio it all works fine.

Please if any one can help me it would be fantastic.

Thanks in advance, much appreciation.

Reda.

6 Answers, 1 is accepted

Sort by
0
Kiara
Top achievements
Rank 1
answered on 29 Sep 2008, 01:51 PM
Reda, I took a peek at your code and my advice would be to update the detail table data through the dsCompanyUsers sql data source taking this sample with hierarchical updates for pointer. You may also intercept the Updated event of the dsCompanyUsers sql data source control or the ItemUpdated event of the grid to see whether the new value for the PermissionName field is passed to the source.

Hope these thoughts are helpful.

Kiara
0
Reda
Top achievements
Rank 1
answered on 29 Sep 2008, 03:27 PM
Hi Kiara,

Thank you soo much for your reply, I tried to intercept the values of the Updated event of the dsCompanyUsers sql data source control but it does not seem to be working. Here is my code:

Protected Sub dsCompanyUsersPerms_Updating(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.SqlDataSourceCommandEventArgs) Handles dsCompanyUsersPerms.Updating

Dim p As SqlParameter

For Each p In e.Command.Parameters
    Response.Write(p.ParameterName +
": " + p.Value + "<br />")
Next
End Sub

Am I doing anything wrong? This updating permission value is making me go crazy. I really have to get it working soon.

Thanks in advance for your help.

Reda.

0
Kiara
Top achievements
Rank 1
answered on 29 Sep 2008, 03:35 PM
I will attempt to help you again, Reda, however I do not have enough information to do so. What seems to be not working when checking the update command parameters values? Is the new PermissionName value passed or not? Do you have PermissionName parameter to update the source data?

Kiara
0
Reda
Top achievements
Rank 1
answered on 29 Sep 2008, 04:04 PM
Kiara, i am not able to see what is being passed as parameters for my "dsCompanyUsers" datasource when updating. What do I have to do to check to see what parameters and values being passed to my stored procedure.

Thank you again....

Reda.
0
Reda
Top achievements
Rank 1
answered on 29 Sep 2008, 05:54 PM
Kiara I solved the problem of the updating.....What I had to do was place all the ID's that had property "read only: true" and "display: false" in the datakey name of the detailed grid. Now it's working perfect.

Thanks for your help in any case, I really appreciate it.

Reda
0
Christopher Lee
Top achievements
Rank 1
answered on 31 Oct 2013, 02:17 PM
Thanks Reda!  You're solution was very helpful to me as well.  
Tags
Grid
Asked by
Reda
Top achievements
Rank 1
Answers by
Kiara
Top achievements
Rank 1
Reda
Top achievements
Rank 1
Christopher Lee
Top achievements
Rank 1
Share this question
or