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

Finding the the control which is inside a RadGrid that caused a postback

1 Answer 30 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Lakshman Venkat
Top achievements
Rank 1
Lakshman Venkat asked on 09 Oct 2010, 10:39 PM
Here is the scenario. I have radgrid which has a Gridbutton as one of the 
colum.When the user click on that button i redirect them to a different page for 
editing. It works fine since i trap the ItemCommand event. But I am wondering is 
there a way I cab get the Control/Id of the control which caused the 
postback in the Page Load rather than the ItemCommand event so that way I 
can skip some of the page_life cycle methods and straight take them to the edit 
page. I am not able to do this if the user clicks a regular button whcih is part 
of the page. but I am not able to get the control/controlid which is inside the 
radgrid which caused the postback. Appreciate any help.


Here is my grid definition

                    <telerik:RadGrid
                        ID="rdgAccountView"
                        runat="server"
                        AllowPaging="True"
                        AllowSorting="True"
                        AutoGenerateColumns="False"
                        OnNeedDataSource="rdgAccountView_OnNeedDataSource"
                        OnItemCreated="rdgAccountView_ItemCreated"
                        OnItemCommand="rdgAccountView_ItemCommand"
                        OnPreRender="rdgAccountView_PreRender"
                        OnLoad="rdgAccountView_OnLoad"
                         OnItemDataBound="rdgAccountView_ItemDataBound"                      
                        >
                        <ClientSettings>
                            <Scrolling AllowScroll="True" UseStaticHeaders="True" ScrollHeight="320"/>
                            <Selecting AllowRowSelect="False" />
                            <Resizing AllowColumnResize="true" ClipCellContentOnResize="true" />
                        </ClientSettings>
                        <ExportSettings>
                            <Pdf FontType="Subset" PaperSize="Letter" />
                            <Excel Format="Html" />
                        </ExportSettings>
                        <MasterTableView
                            Width="100%"
                            NoDetailRecordsText="No Account Records Found"
                            CurrentResetPageIndexAction="SetPageIndexToFirst"
                            Dir="LTR"
                            Frame="Border"
                            TableLayout="Auto"
                            DataKeyNames="ParentIdentifier">
                        
                            <RowIndicatorColumn CurrentFilterFunction="NoFilter" FilterListOptions="VaryByDataType"
                                Visible="False">
                                <HeaderStyle Width="20px" />
                            </RowIndicatorColumn>
                            <Columns>
                                <telerik:GridButtonColumn ButtonType="ImageButton" ImageUrl="../../App_Themes/Default/DataEditingImages/Edit.gif"
                                    CommandName="EditAccountView" Text="Edit" UniqueName="EditFromAccountView">
                                    <HeaderStyle Width="20px" />
                                </telerik:GridButtonColumn>
                                <telerik:GridBoundColumn DataField="FirstName" Groupable="False" HeaderText="First Name"
                                    UniqueName="Work Queue" ReadOnly="True" ItemStyle-HorizontalAlign="Center" HeaderStyle-HorizontalAlign="Center"
                                    HeaderStyle-Width="100px" HeaderStyle-Wrap="true" AutoPostBackOnFilter="true">
                                </telerik:GridBoundColumn>
                                <telerik:GridBoundColumn DataField="LastName" Groupable="False" HeaderText="Last Name"
                                    UniqueName="Work Queue" ReadOnly="True" ItemStyle-HorizontalAlign="Center" HeaderStyle-HorizontalAlign="Center"
                                    HeaderStyle-Width="100px" HeaderStyle-Wrap="true" AutoPostBackOnFilter="true">
                                </telerik:GridBoundColumn>
                                <telerik:GridButtonColumn ConfirmText="Are you sure you want to delete this Account?"
                                    ButtonType="ImageButton" Visible="True" ImageUrl="../../App_Themes/Default/DataEditingImages/Delete.gif"
                                    CommandName="DeleteAccount" Text="Delete" UniqueName="DeleteAccountColumn">
                                    <HeaderStyle Width="20px" />
                                </telerik:GridButtonColumn>
                            </Columns>
                            <EditFormSettings>
                                <EditColumn CurrentFilterFunction="NoFilter" FilterListOptions="VaryByDataType">
                                </EditColumn>
                                <PopUpSettings ScrollBars="None"></PopUpSettings>
                            </EditFormSettings>
                        </MasterTableView>
                        <ClientSettings AllowColumnsReorder="True">
                        </ClientSettings>
                    </telerik:RadGrid>

1 Answer, 1 is accepted

Sort by
0
Iana Tsolova
Telerik team
answered on 14 Oct 2010, 12:13 PM
Hi Lakshman,

In order to track the button click on Page_Load, I would suggest that you use GridTemplateColumn with a Button in the ItemTemplate. Then on Page_Load the request event target will contain the ID of this button.
ANother option is to use GridHyperLinkColumn and set its NavigateUlr property so the use is automatically redirected to the edit page.

Check it out and let me know if this works for you.

Best wishes,
Iana
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
General Discussions
Asked by
Lakshman Venkat
Top achievements
Rank 1
Answers by
Iana Tsolova
Telerik team
Share this question
or