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

Find Control in a radwindow maultipageview

3 Answers 267 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Babu Puchakayala
Top achievements
Rank 1
Babu Puchakayala asked on 31 Jul 2010, 09:55 PM
Hi Telerik Team,

I Implemented popup window with radtabs option in it. I have textboxe and dropdownlist in second tab.  (see diagram 1 below) When I am trying to find control of that textbox i am getting error like "Object reference not set to an instance of an object." Here is my  code. Can you help me how to solve this issue. Thanks.

here is my code
<telerik:RadWindow ID="WinEditForm" runat="server" ShowContentDuringLoad="false"
        Width="650px" Height="400px" Title="Action" Behaviors="Default" Animation="FlyIn">
        <ContentTemplate>
            <div style="padding-top: 15px; padding-left: 10px">
                <asp:UpdatePanel runat="server" ID="UpEditForm" OnUnload="RegisterUpdatePanel4">
                    <ContentTemplate>
                        <div style="padding-right: 20px; padding-top: 15px; text-align: center">
                            <table class="customFont" cellspacing="5" width="100%">
                                <tr>
                                    <td>
                                        <telerik:RadTabStrip runat="server" ID="RadTabStrip1" Orientation="HorizontalTop"
                                            SelectedIndex="0" MultiPageID="RadMultiPage1" Align="Left">
                                            <Tabs>
                                                <telerik:RadTab Text="Task Data" PageViewID="RadPageView1">
                                                </telerik:RadTab>
                                                <telerik:RadTab Text="Notes" PageViewID="RadPageView2">
                                                </telerik:RadTab>
                                            </Tabs>
                                        </telerik:RadTabStrip>
                                        <telerik:RadMultiPage runat="server" ID="RadMultiPage1" SelectedIndex="0">
                                            <telerik:RadPageView runat="server" ID="RadPageView1">
                                                <table id="Table3" cellspacing="1" cellpadding="1" width="350" border="0">
                                                    <tr>
                                                        <td>
                                                        </td>
                                                        <td>
                                                        </td>
                                                    </tr>
                                                    <br />
                                                    <tr>
                                                        <td>
                                                            Clarify Account Nbr:
                                                        </td>
                                                        <td align="left">
                                                            <asp:TextBox ID="TextBox1" runat="server">
                                                            </asp:TextBox>
                                                        </td>
                                                    </tr>
                                                    <tr>
                                                        <td>
                                                            Site ID:
                                                        </td>
                                                        <td align="left">
                                                            <asp:TextBox ID="TextBox2" runat="server" TabIndex="1">
                                                            </asp:TextBox>
                                                        </td>
                                                    </tr>
                                                    <tr>
                                                        <td>
                                                            Quote ID:
                                                        </td>
                                                        <td align="left">
                                                            <asp:TextBox ID="TextBox3" runat="server" TabIndex="2">
                                                            </asp:TextBox>
                                                        </td>
                                                    </tr>
                                                    <tr>
                                                        <td>
                                                            EDP Created?:
                                                        </td>
                                                        <td align="left">
                                                            <asp:CheckBox ID="CheckBox1" runat="server" TabIndex="3"></asp:CheckBox>
                                                        </td>
                                                    </tr>
                                                    <tr>
                                                        <td align="right" colspan="2">
                                                            <asp:Button ID="btnUpdate" runat="server" Text="Update" OnClick="btnUpdate_Click">
                                                            </asp:Button>
                                                            <asp:Button ID="btnCancel" Text="Cancel" runat="server" CausesValidation="False"
                                                                CommandName="Cancel"></asp:Button>
                                                        </td>
                                                    </tr>
                                                </table>
                                            </telerik:RadPageView>
                                            <telerik:RadPageView runat="server" ID="RadPageView2">
                                                <table id="Table2" cellspacing="1" cellpadding="1" width="350" border="0">
                                                    <tr>
                                                        <td>
                                                            <br />
                                                            <table id="Tablenotes">
                                                                <tr>
                                                                    <td align="left">
                                                                        Note Type :
                                                                        <asp:DropDownList ID="DropDownList1" runat="server">
                                                                        </asp:DropDownList>
                                                                    </td>
                                                                    <td align="left">
                                                                    </td>
                                                                </tr>
                                                                <tr>
                                                                    <td align="left" colspan="2">
                                                                        Note Description
                                                                    </td>
                                                                </tr>
                                                                <tr>
                                                                    <td align="left">
                                                                        <asp:TextBox ID="TextBox4" runat="server" TextMode="MultiLine" Rows="2" Width="300px"></asp:TextBox>
                                                                    </td>
                                                                    <td>
                                                                        <asp:ImageButton ID="ImageButton3" OnClick="btnAddNote_Click" runat="server" ToolTip="Add Note"
                                                                            ImageUrl="~/Images/add-icon.png" />
                                                                        <asp:ImageButton Visible="false" ToolTip="Update" OnClick="imgbtnNotesUpdate_Click"
                                                                            ID="imgbtnNotesUpdate" runat="server" ImageUrl="~/Images/accept-icon.png" />
                                                                        <asp:ImageButton Visible="false" ToolTip="Cancel" OnClick="imgbtnNotesCancel_Click"
                                                                            ID="imgbtnNotesCancel" runat="server" ImageUrl="~/Images/delete-icon.png" />
                                                                    </td>
                                                                </tr>
                                                            </table>
                                                        </td>
                                                    </tr>
                                                    <tr>
                                                        <td>
                                                            <div style="overflow: auto; height: 160px">
                                                                <asp:GridView ID="gvNotes" BorderColor="#004000" runat="server" AutoGenerateColumns="false"
                                                                    BackColor="White" BorderWidth="1px" BorderStyle="Solid" CellSpacing="0" Width="100%"
                                                                    OnSelectedIndexChanged="gvNotes_SelectedIndexChanged" OnRowDataBound="gvNotes_RowDataBound">
                                                                    <HeaderStyle Height="20px" BackColor="#004000" Font-Size="8pt" Font-Bold="True" ForeColor="White"
                                                                        HorizontalAlign="Center" BorderColor="White" BorderWidth="0px" />
                                                                    <PagerSettings Mode="NumericFirstLast"></PagerSettings>
                                                                    <RowStyle ForeColor="#000000" Font-Size="8pt" HorizontalAlign="Left" BorderWidth="1px"
                                                                        BorderColor="#004000" />
                                                                    <AlternatingRowStyle Font-Size="8pt" ForeColor="#000000" BackColor="#F5F5E9" BorderWidth="1px"
                                                                        BorderColor="#004000" />
                                                                    <PagerStyle HorizontalAlign="Right" Font-Bold="true" Font-Size="8pt" />
                                                                    <Columns>
                                                                        <asp:TemplateField Visible="false">
                                                                            <ItemTemplate>
                                                                                <asp:Label ID="lblonID" runat="server" Text='<%# Bind("onID") %>'></asp:Label>
                                                                            </ItemTemplate>
                                                                            <ItemStyle HorizontalAlign="Left" />
                                                                        </asp:TemplateField>
                                                                        <asp:BoundField HeaderText="Note Description" DataField="Description" />
                                                                        <asp:BoundField HeaderText="Note Type" DataField="Type" />
                                                                        <asp:BoundField HeaderText="Created By" DataField="CreatedBy" />
                                                                        <asp:BoundField DataFormatString="{0:MM/dd/yyyy}" HeaderText="Created Date" DataField="CreationDate" />
                                                                    </Columns>
                                                                </asp:GridView>
                                                            </div>
                                                        </td>
                                                    </tr>
                                                </table>
                                            </telerik:RadPageView>
                                        </telerik:RadMultiPage>
                                    </td>
                                </tr>
                    </ContentTemplate>
                </asp:UpdatePanel>
            </div>
        </ContentTemplate>
    </telerik:RadWindow>


protected void btnAddNote_Click(object sender, EventArgs e)
    {
 
        clsTaskUpdates_BL objBL = new clsTaskUpdates_BL();
        string strName = Session["UserName"].ToString();
 
        string OrdID = (string)Session["orderId"];
        RadPageView PageView = (RadPageView)WinEditForm.ContentContainer.FindControl("RadPageView2");
        TextBox NoteTxt = (TextBox)PageView.FindControl("txtNoteDesc");
        string NoteDesc = NoteTxt.Text;
        DropDownList DDL = (DropDownList)PageView.FindControl("ddlNoteType");
        string NoteType = DDL.Text;
}

I also tried another way but no luck

string OrdID = (string)Session["orderId"];
        string NoteType = (WinEditForm.ContentContainer.FindControl("RadPageView2").FindControl("ddlNoteType") as DropDownList).Text;
        string NoteDesc = (WinEditForm.ContentContainer.FindControl("RadPageView2").FindControl("txtNoteDesc") as TextBox).Text;


Please let me know how to find the answer

3 Answers, 1 is accepted

Sort by
0
Babu Puchakayala
Top achievements
Rank 1
answered on 31 Jul 2010, 09:58 PM
I also tried this way but no luck ...

TextBox Babu = WinEditForm.ContentContainer.FindControl("txtNoteDesc") as TextBox;
0
Accepted
Nikolay Rusev
Telerik team
answered on 05 Aug 2010, 08:27 AM
Hello Babu,

If you examine the markup that you have pasted in RadPageView2 there is no definition of TextBox with ID txtNoteDesc and DropDownList with ID ddlNoteType. Please not the ID of the controls this particular page view:
/copy from markup/
....
 <telerik:RadPageView runat="server" ID="RadPageView2">
....
 <asp:DropDownList ID="DropDownList1" runat="server"></asp:DropDownList>
....
<asp:TextBox ID="TextBox4" runat="server" TextMode="MultiLine" Rows="2" Width="300px"></asp:TextBox>
...
 </telerik:RadPageView>
.....


Regards,
Nikolay
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
0
Babu Puchakayala
Top achievements
Rank 1
answered on 05 Aug 2010, 03:03 PM
Hi Nikolay,

I have multiple radwindows. I used another radwindows ids. Any way thanks for point out my mistake
Tags
Grid
Asked by
Babu Puchakayala
Top achievements
Rank 1
Answers by
Babu Puchakayala
Top achievements
Rank 1
Nikolay Rusev
Telerik team
Share this question
or