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

[Solved] GridEditFormItem in Itemcommand event

2 Answers 257 Views
Grid
This is a migrated thread and some comments may be shown as answers.
chithuraj
Top achievements
Rank 1
chithuraj asked on 19 Aug 2009, 03:07 PM
Hi,
    I have the Rad grid, which has EditFormSettings .  I need to find the to find the Grideditformitem in the item command event. I am not
 able to find the controls in GridEditformitem. For me it is coming as null. Any Ides.


Please Help Me!!
Any help will be appreciated..

Thanks,
Chithu
<EditFormSettings EditFormType="Template" ColumnNumber="3" CaptionFormatString="Add Manufacturer and Model"
                                                                        <FormTemplate> 
                                                                            <table id="tbl1Select" border="0"
                                                                                <tr> 
                                                                                    <td style="border: 0px"
                                                                                        Manufacturer: 
                                                                                    </td> 
                                                                                    <td style="border: 0px"
                                                                                        <asp:DropDownList Width="150px" CssClass="cssField" ID="ddlManufacturer" runat="server"
                                                                                        </asp:DropDownList> 
                                                                                    </td> 
                                                                                </tr> 
                                                                                <tr> 
                                                                                    <td style="border: 0px"
                                                                                        Model: 
                                                                                    </td> 
                                                                                    <td style="border: 0px"
                                                                                        <asp:TextBox ID="txtModel" CssClass="cssfield" runat="server"></asp:TextBox> 
                                                                                    </td> 
                                                                                </tr> 
                                                                            </table> 
                                                                            <table> 
                                                                                <tr> 
                                                                                    <td> 
                                                                                        <asp:LinkButton ID="btnCancel" Text="Cancel" runat="server" CausesValidation="False" 
                                                                                            CommandName="Cancel"
                                                                                        </asp:LinkButton> 
                                                                                        <asp:LinkButton ID="btnAdd" Text="Add" runat="server" CausesValidation="False" CommandName="Add"></asp:LinkButton> 
                                                                                    </td> 
                                                                                </tr> 
                                                                            </table> 
                                                                        </FormTemplate> 
                                                                        <EditColumn UniqueName="EditCommandColumn1"
                                                                        </EditColumn> 
                                                                    </EditFormSettings> 

 protected void radAddproducts_ItemCommand(object source, GridCommandEventArgs e) 
    { 
        if (e.CommandName == "Cancel") 
        { 
            e.Canceled = true
            radAddproducts.MasterTableView.ClearEditItems();  
        } 
 
        if (e.CommandName == "Add") 
        { 
 
            HiddenField hdnManufacturer; 
            if (e.Item is GridDataItem) 
            { 
                hdnManufacturer = (HiddenField)e.Item.FindControl("hdnmanufacturer"); 
            } 
            if (e.Item is GridEditFormItem) 
            { 
                DropDownList dlManufacturer =     (DropDownList)e.Item.FindControl("ddlManufacturer"); 
             
            } 
          
            
           
        } 
    } 

2 Answers, 1 is accepted

Sort by
0
Princy
Top achievements
Rank 2
answered on 20 Aug 2009, 04:46 AM
Hello Chituraj,

You can try out the following code instead to access the DropDownList on clicking the button:
c#:
protected void RadGrid_ItemCommand(object source, GridCommandEventArgs e) 
    { 
        if (e.CommandName == "Add"
        { 
            GridDataItem item = (GridDataItem)e.Item; 
            hdnManufacturer  = (HiddenField)item.FindControl("hdnmanufacturer"); 
            DropDownList dlManufacturer = (DropDownList)item.EditFormItem.FindControl("ddlManufacturer");           
                 
        } 
    } 

Thanks
Princy.
0
Umer
Top achievements
Rank 1
answered on 09 Aug 2013, 11:23 AM
I fix it by my own
Tags
Grid
Asked by
chithuraj
Top achievements
Rank 1
Answers by
Princy
Top achievements
Rank 2
Umer
Top achievements
Rank 1
Share this question
or