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

Update/Cancel not working in UserControl in Grid

2 Answers 77 Views
Grid
This is a migrated thread and some comments may be shown as answers.
russ
Top achievements
Rank 1
russ asked on 27 Jul 2010, 09:15 PM
I have a RadGrid that implements a web user control for the edits.  I've attempted to follow replicate as much as I could from the demo at http://demos.telerik.com/aspnet-ajax/grid/examples/dataediting/usercontroleditform/defaultcs.aspx but for some reason, my buttons aren't kicking off the update command on the RadGrid.  I had all of the data populating, but started over so now I only have a couple of the items populating on the user control.  All I'm concerned with right now is getting the btnSubmit to work.. I imagine that after I get that working, I'll be able to get the rest of them working

radgrid
<telerik:RadGrid ID="rgDocuments" runat="server" AutoGenerateColumns="False" GridLines="None"
    AllowSorting="True" ShowStatusBar="true"
    OnUpdateCommand="rgDocuments_UpdateCommand" onitemcommand="rgDocuments_ItemCommand"
    >
    <MasterTableView CommandItemDisplay="Top" DataKeyNames="DocumentId" >
        <commanditemsettings addnewrecordtext="Add new Document" />
        <Columns>
        <telerik:GridEditCommandColumn UniqueName="EditCommandColumn"></telerik:GridEditCommandColumn>
            <telerik:GridBoundColumn DataField="DocumentId" HeaderText="ID" UniqueName="ID">
                <ItemStyle Font-Bold="False" Font-Italic="False" Font-Overline="False"
                    Font-Strikeout="False" Font-Underline="False" VerticalAlign="Top" Wrap="True" />
            </telerik:GridBoundColumn>
            <telerik:GridBoundColumn DataField="Title" HeaderText="Title" UniqueName="Title">
                <ItemStyle Font-Bold="False" Font-Italic="False" Font-Overline="False"
                    Font-Strikeout="False" Font-Underline="False" VerticalAlign="Top" Wrap="True" />
            </telerik:GridBoundColumn>
            <telerik:GridBoundColumn DataField="Description" HeaderText="Description" UniqueName="Description">
                <ItemStyle Font-Bold="False" Font-Italic="False" Font-Overline="False"
                    Font-Strikeout="False" Font-Underline="False" VerticalAlign="Top" Wrap="True" />
            </telerik:GridBoundColumn>
            <telerik:GridBoundColumn DataField="Author" HeaderText="Author" UniqueName="Author" >
                <ItemStyle Font-Bold="False" Font-Italic="False" Font-Overline="False"
                    Font-Strikeout="False" Font-Underline="False" VerticalAlign="Top" Wrap="True" />
            </telerik:GridBoundColumn>
            <telerik:GridBoundColumn DataField="Active" DataType="System.Boolean" HeaderText="Active"
                UniqueName="Active">
                <ItemStyle Font-Bold="False" Font-Italic="False" Font-Overline="False"
                    Font-Strikeout="False" Font-Underline="False" VerticalAlign="Top" Wrap="True" />
            </telerik:GridBoundColumn>
            <telerik:GridBoundColumn DataField="DocumentCategoryId" DataType="System.Int32" HeaderText="Category"
                UniqueName="DocumentCategoryId">
                <ItemStyle Font-Bold="False" Font-Italic="False" Font-Overline="False"
                    Font-Strikeout="False" Font-Underline="False" VerticalAlign="Top" Wrap="True" />
            </telerik:GridBoundColumn>
        </Columns>
        <EditFormSettings UserControlName="~/UserControls/AddUpdateDocument.ascx" EditFormType="WebUserControl">
            <EditColumn UniqueName="EditCommandColumn1" />
        </EditFormSettings>
    </MasterTableView>
    <ClientSettings>
        <Selecting AllowRowSelect="True" />
    </ClientSettings>
</telerik:RadGrid>

user control
<%@ Control Language="C#" AutoEventWireup="True" CodeBehind="AddUpdateDocument.ascx.cs"
    Inherits="PortalAdmin.AddUpdateDocument" %>
<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
<style type="text/css">
    .style1
    {
        text-align: right;
        width: 65px;
    }
</style>
    <table style="width: 100%; border: 1px solid #828282;">
        <tr>
            <td colspan="3">
                <asp:Label ID="Label9" runat="server" Style="font-weight: bold;" Text="Add/Update Document"></asp:Label>
            </td>
        </tr>
        <tr>
            <td style="width: 116px; text-align: right;">
                <asp:Label ID="Label7" runat="server" Style="text-align: right;" Text="Document ID:" />
            </td>
            <td style="width: 449px">
                <telerik:radtextbox id="tbDocumentId" runat="server" maxlength="255" readonly="True"
                    width="41px" Text='<%# DataBinder.Eval(Container, "DataItem.DocumentId") %>'>
                </telerik:radtextbox>
            </td>
            <td>
                  
                <asp:Label ID="Label11" runat="server" Text="Category:"></asp:Label>
                <telerik:RadComboBox ID="cbCategories" Runat="server" Width="255px" >
                </telerik:RadComboBox>
            </td>
        </tr>
        <tr>
            <td style="width: 116px; text-align: right;">
                <asp:Label ID="Label1" runat="server" Style="text-align: right;" Text="Title: " />
            </td>
            <td style="width: 449px">
                <telerik:radtextbox id="tbTitle" runat="server" maxlength="255" width="435px" Text='<%# DataBinder.Eval(DataItem, "Title") %>'>
                                    </telerik:radtextbox>
            </td>
            <td style="text-align:center;">
                <asp:CheckBox ID="cbActive" runat="server" Text="Active?" />
                <asp:CheckBox ID="cbArchive" runat="server" Text="Archived?" style="padding-left: 10px;"/>
            </td>
        </tr>
        <tr>
            <td style="width: 116px; vertical-align: top; text-align: right;">
                <asp:Label ID="Label2" runat="server" Text="Description: " Style="text-align: right;" />
            </td>
            <td style="width: 449px">
                <telerik:radtextbox id="tbDescription" runat="server" maxlength="500" rows="7" textmode="MultiLine"
                    width="435px" Text='<%# DataBinder.Eval(DataItem, "Description") %>'>
                                    </telerik:radtextbox>
            </td>
            <td style="vertical-align: top;">
                <asp:Label ID="Label10" runat="server" Text="Current File Info"
                    Font-Underline="True"></asp:Label>
                <table style="width:100%;">
                    <tr>
                        <td class="style1">
                            <asp:Label ID="Label8" runat="server" Style="text-align: right;" Text="Name:" />
                        </td>
                        <td>
                            <asp:Label ID="lnkName" runat="server"></asp:Label>
                        </td>
                    </tr>
                    <tr>
                        <td class="style1">
                            <asp:Label ID="Label12" runat="server" Style="text-align: right;"
                                Text="Location:" />
                        </td>
                        <td>
                            <asp:Label ID="lblLocation" runat="server"></asp:Label>
                        </td>
                    </tr>
                    <tr>
                        <td class="style1">
                            <asp:Label ID="Label15" runat="server" Style="text-align: right;"
                                Text="Type:" />
                        </td>
                        <td>
                            <asp:Label ID="lblType" runat="server"></asp:Label>
                        </td>
                    </tr>
                    <tr>
                        <td class="style1">
                            <asp:Label ID="Label14" runat="server" Style="text-align: right;"
                                Text="Size:" />
                        </td>
                        <td>
                            <asp:Label ID="lblSize" runat="server"></asp:Label>
                        </td>
                    </tr>
                </table>
                <br />
            </td>
        </tr>
        <tr>
            <td style="width: 116px; text-align: right;">
                <asp:Label ID="Label3" runat="server" Text="Author: " Style="text-align: right;" />
            </td>
            <td style="width: 449px">
                <telerik:radtextbox id="tbAuthor" runat="server" maxlength="255" width="435px">
                                    </telerik:radtextbox>
            </td>
            <td style="text-align: right">
                <telerik:RadUpload ID="upload" Runat="server"
                    ControlObjectsVisibility="None" Height="21px" MaxFileInputsCount="1"
                    Width="255px">
                </telerik:RadUpload>
            </td>
        </tr>
        <tr>
            <td colspan="3" style="text-align: right; width: 100%;">
                <asp:Button ID="btnSubmit" runat="server" Text="Submit Document"
                    CausesValidation="True"
                    CommandName="Update"/>
                <asp:Button ID="btnCancel" runat="server" CausesValidation="False"
                    CommandName="Cancel" Text="Cancel" />
            </td>
        </tr>
    </table>

2 Answers, 1 is accepted

Sort by
0
russ
Top achievements
Rank 1
answered on 28 Jul 2010, 01:40 PM
Another thing that I forgot to mention, I am using methods in another method class to get the data, and to attempt to update it.  Or at least that's how I want to do it.
0
russ
Top achievements
Rank 1
answered on 28 Jul 2010, 02:14 PM
please disregard.  I had the grid setup to populate through the page_load method.  I moved that code to the needsource method, and the update command seems to be working now.
Tags
Grid
Asked by
russ
Top achievements
Rank 1
Answers by
russ
Top achievements
Rank 1
Share this question
or