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

How to access GridButtonColumn?

1 Answer 217 Views
Grid
This is a migrated thread and some comments may be shown as answers.
myrad
Top achievements
Rank 1
myrad asked on 29 Oct 2010, 02:52 PM
Hello,
I have got RadGrid placed inside RadPanelBar. I've got GridButtonColumn ("Submit"). When user click of submit button it ask for confirmation. I want to submit details when user click on OK button. How do access the GridButtonColumn ("Submit") to submit details.  

Here is my code..


<
telerik:RadPanelBar ID="RadPanelBar1" runat="server">

 

 

<Items>

 

<telerik:RadPanelItem runat="server" Text="Journals" Font-Bold="False">

 

 

 

<Items>

 

 

 

 

<telerik:RadPanelItem runat="server" Value="PanelItem1">

 

 

 

 

<ItemTemplate>

 

<telerik:RadGrid ID="TestRadGrid" runat="server" AutoGenerateColumns="False">

 

 

 

<MasterTableView>

 

<Columns>  

 

 

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

 

 

 

<telerik:GridButtonColumn UniqueName="Submit" Text="Submit" ButtonType="LinkButton"  

 

 

CommandName="Submit" ConfirmDialogType="RadWindow" ConfirmText="Are you sure you want to submit this request?">  
<
/telerik:GridButtonColumn>

 

</Columns

 

 

</MasterTableView 

 

 

</telerik:RadGrid

 

 

 

</ItemTemplate 

 

 

</telerik:RadPanelItem 

 

 

</Items 

 

 

</telerik:RadPanelItem>

 

 

 

 

</Items 

 

</telerik:RadPanelBar>


Many thanks.

 

 

 

 

 

1 Answer, 1 is accepted

Sort by
0
Shinu
Top achievements
Rank 2
answered on 01 Nov 2010, 07:39 AM
Hi Myrad,


Since you set the CommandName for ButtonColumn, the ItemCommand event will fire on clicking the button. In the ItemCommand event, get the corresponding item (e.Item) and access the cell values using ColumnUniqueName.
 
Code:
protected void RadGrid1_ItemCommand(object source, GridCommandEventArgs e)
{
    if (e.CommandName == "Submit")
    {
        GridDataItem item = (GridDataItem)e.Item;
        string value = item["ContactName"].Text;    
    }
}



-Shinu.
Tags
Grid
Asked by
myrad
Top achievements
Rank 1
Answers by
Shinu
Top achievements
Rank 2
Share this question
or