Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
355
How to get the value of a textbox which is inside a webdatamenu?
posted

This is my webdatamenu:

<ig:WebDataMenu ID="Mimenu" runat="server" Width="100%" Height="40px">
<Items>
<ig:DataMenuItem Key="Numero" >

<Template>

  <%--The value of the text box is according to what the user enters ... although by default is number 1 --%>


<asp:TextBox runat="server" ToolTip="N&#250;mero" Key="NumeroP"
Rows="0" Columns="0" Width="30px">1</asp:TextBox>


</Template>
</ig:DataMenuItem>

</Items>
</ig:WebDataMenu>

---------------------------------------------------------------

in the CondeBehind

int NoP = Convert.ToInt32(Mimenu.Items.FindDataMenuItemByText("NumeroP").Text);

Here I want to get the value that brings the box but I can not always throws me an error:

Object reference not set to an instance of an object.

Thanks very much!

Before it got so

<igtbar:ultrawebtoolbar id="Mimenu" runat="server" Width="100%" Height="30px" ItemWidthDefault="150px">


<Items>

<igtbar:TBTextBox Rows="0" ToolTip="N&#250;mero" Key="NumeroP" Columns="0">
</igtbar:TBTextBox>
</Items>
</igtbar:ultrawebtoolbar>

------------------------------------------------------------------------------------------

int NoP = Convert.ToInt32(Mimenu.Items.FromKeyTextBox("NumeroP").Text);

Parents
  • 8421
    Verified Answer
    posted

    Hello Mary,

    First you would need to find the DataMenuItem that contains the TextBox control:

    DataMenuItem item = Mimenu.Items.FindDataMenuItemByKey("Numero");

    Once you have this, then you can use FindControl get access to the control within the Template:

    TextBox numeroP = item.FindControl("NumeroP") as TextBox;

    if (numeroP != null) {

       int NoP = Convert.ToInt32(numeroP.Text);

    }

    For more information about using FindControl, please see the MSDN documentation on the method.

Reply Children