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

RadGrid with 2 GridButtonColumns

3 Answers 79 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Herman Gouw
Top achievements
Rank 2
Herman Gouw asked on 14 Jul 2010, 04:23 PM
Hi,

In my current project I have a RadGrid with the following columns:
- Name of type GridBoundColumn
- Email of type GridBoundColumn
- TestEmail of type GridButtonColumn
- Mobile of type GridBoundColumn
- TestSMS of type GridButtonColumn

The web page is available on http://www.gouw.ws/RadGridWithButtons.aspx

Can you please tell me:
1. On each row,
    - how to disable the TestEmail button if the Email column is empty, and
    - how to disable the TestSMS button if the Mobile column is empty
2. How to process on the code behind when the TestEmail button or TestSMS button is clicked?

The ASPX is given as follows:
<telerik:RadGrid ID="radGrid" AutoGenerateColumns="false" AllowSorting="true" OnNeedDataSource="radGrid_NeedDataSource" runat="server">
    <ClientSettings>
        <Scrolling UseStaticHeaders="true" />
    </ClientSettings>
    <MasterTableView TableLayout="Fixed">
        <Columns>
            <telerik:GridBoundColumn DataField="Name" DataType="System.String" HeaderStyle-Width="20%" HeaderText="Name" HeaderStyle-HorizontalAlign="Left" ItemStyle-HorizontalAlign="Left" AllowSorting="true" UniqueName="Name" />
            <telerik:GridBoundColumn DataField="Email" DataType="System.String" HeaderStyle-Width="20%" HeaderText="Email" HeaderStyle-HorizontalAlign="Left" ItemStyle-HorizontalAlign="Left" AllowSorting="true" UniqueName="Email" />
            <telerik:GridButtonColumn ButtonType="PushButton" Text="Test Email" HeaderStyle-Width="5%" HeaderText="Test" HeaderStyle-HorizontalAlign="Center" CommandName="TestEmail" UniqueName="TestEmail" />
            <telerik:GridBoundColumn DataField="Mobile" DataType="System.String" HeaderStyle-Width="20%" HeaderText="Mobile (SMS)" HeaderStyle-HorizontalAlign="Left" ItemStyle-HorizontalAlign="Left" AllowSorting="true" UniqueName="Mobile" />
            <telerik:GridButtonColumn ButtonType="PushButton" Text="Test SMS" HeaderStyle-Width="5%" HeaderText="Test" HeaderStyle-HorizontalAlign="Center" CommandName="TestSMS" UniqueName="TestSMS" />
        </Columns>
    </MasterTableView>
</telerik:RadGrid>

Regards,
Herman

3 Answers, 1 is accepted

Sort by
0
Herman Gouw
Top achievements
Rank 2
answered on 15 Jul 2010, 06:23 AM
Please disregard this thread as I have found out both solutions. Thanks.
0
Accepted
Princy
Top achievements
Rank 2
answered on 15 Jul 2010, 07:13 AM
 
0
rock
Top achievements
Rank 1
answered on 15 Jul 2010, 01:46 PM
hi ..
u can write code in ItemDataBound event of radgrid.and don't take bound colum. use template colum and take telerik control in Item tample/EditItem Tamplate. also for button use tamplate colum
and put conditon in Item Datatbound event like following

if (e.Item is GridDataItem)
        {

                 GridDataItem item = (GridDataItem)e.Item;
            label Email = (label)item["status"].FindControl("lblEmail");
// here status is columname or unique name and lbmail is image button and lblemail is control which is diplay emailid.
            ImageButton reptbutton = (ImageButton)item["status"].FindControl("lbmail");

          
            if (Email .Value == " ")
            {
                reptbutton.Enable=False;
            }
           else            {
                 reptbutton.Enable=true;
            }
        }


may be useful for u.

Tags
Grid
Asked by
Herman Gouw
Top achievements
Rank 2
Answers by
Herman Gouw
Top achievements
Rank 2
Princy
Top achievements
Rank 2
rock
Top achievements
Rank 1
Share this question
or