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

[Solved] OnItemCommand only returning RowClick

3 Answers 123 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Phil Jones
Top achievements
Rank 1
Phil Jones asked on 14 Aug 2009, 11:09 AM

Sorry if I've missed the point here, but here's my issue.

I've got a RadGrid  declared like this

 

<telerik:RadGrid ID="RadGrid1" GridLines="None" runat="server" AllowPaging="True"

                    AutoGenerateColumns="False" OnUpdateCommand="UpdateItem" OnInsertCommand="UpdateItem"

                    AutoGenerateDeleteColumn="false" AutoGenerateEditColumn="false" OnDeleteCommand="DeleteItem"

                    Skin="WebBlue" OnNeedDataSource="NeedDataSource" Width="50%" OnItemCommand="LawyerSelected">

                    <PagerStyle Mode="NextPrevAndNumeric" />

                    <MasterTableView CommandItemDisplay="TopAndBottom" AutoGenerateColumns="false" DataKeyNames="LawyerID"

                        BorderColor="Black" BorderWidth="1px" GridLines="Both">

                        <Columns>

                            <telerik:GridBoundColumn DataField="LawyerID" DataType="System.Guid" AllowFiltering="false"

                                HeaderText="LawyerID" UniqueName="LawyerID" Visible="False">

                            </telerik:GridBoundColumn>

                            <telerik:GridBoundColumn DataField="Name" HeaderText="Name" UniqueName="Name">

                            </telerik:GridBoundColumn>

                            <telerik:GridBoundColumn DataField="Company" HeaderText="Company" UniqueName="Company">

                            </telerik:GridBoundColumn>

                            <telerik:GridTemplateColumn UniqueName="TemplateColumn2">

                                <ItemTemplate>

                                    <asp:LinkButton ID="EditButton" CommandName="Edit" CommandArgument="Edit" Text="Edit" runat="server"></asp:LinkButton>

                                </ItemTemplate>

                                <EditItemTemplate>

                                    <asp:LinkButton ID="UpdateButton" CommandName="Update" CommandArgument="Update" Text="Update" runat="server"></asp:LinkButton>

                                    <asp:LinkButton ID="CancelButton" CommandName="Cancel" CommandArgument="Cancel" Text="Cancel" runat="server"></asp:LinkButton>

                                </EditItemTemplate>

                            </telerik:GridTemplateColumn>

                        </Columns>

                        <EditFormSettings ColumnNumber="2" CaptionDataField="Name" CaptionFormatString="Editing Lawyer {0}">

                            <FormTableItemStyle Wrap="false" />

                        </EditFormSettings>

                    </MasterTableView>

                    <ClientSettings EnablePostBackOnRowClick="true"></ClientSettings>

                </telerik:RadGrid>

 

The important bits being that the auto edit feature is turned off.

 

What I want to be able to do is either click on the edit link (Edit Button) to edit the row or click on a row to do something else (display related information).

For some reason when I click on a row the CommandName that’s returned is usually rowClick and not Edit.

3 Answers, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 14 Aug 2009, 11:57 AM
Hi Phil,

The CommandName will be RowClick since you have set the EnablePostBackOnRowClick property to true.  If you want to perform an edit opeartion while clicking the row you can try the following approach.

CS:
 
protected void RadGrid1_ItemCommand(object source, GridCommandEventArgs e) 
    if (e.CommandName == "RowClick"
    { 
        e.Item.Edit = true;            
    } 
    RadGrid1.Rebind(); 

-Shinu
0
Phil Jones
Top achievements
Rank 1
answered on 14 Aug 2009, 12:02 PM
Hi - thanks for the propmt reply - so I cannot have a separate edit click and a rowclick if I have set the EnablePostBackOnRowClick property to true?

I want to have two separate events happen depending on whether the user clicks the row or the edit link...
0
Chirag Dedhia
Top achievements
Rank 1
answered on 02 Feb 2010, 01:12 PM
Hi Phil,

I am also looking for a similar scenario. Did you got a solution for this?

Thanks & Regards
Chirag Dedhia
Tags
Grid
Asked by
Phil Jones
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Phil Jones
Top achievements
Rank 1
Chirag Dedhia
Top achievements
Rank 1
Share this question
or