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ú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úmero" Key="NumeroP" Columns="0"></igtbar:TBTextBox></Items> </igtbar:ultrawebtoolbar>
------------------------------------------------------------------------------------------
int NoP = Convert.ToInt32(Mimenu.Items.FromKeyTextBox("NumeroP").Text);
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); }
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.
Thanks very much
I was a big help
But now I find detail, if I want to enter a value in the text box automatically sends me to the event webdatamenu and I can not enter my courage ... do not know why this happens or I am doing wrong
sorry for the inconvenience that may have caused my questionthank you very much
<ig:WebDataMenu ID="Mimenu" runat="server" Width="100%" Height="40px"
AutoPostBackFlags-ItemClick="On" OnItemClick="BH_ButtonClicked"
><Items><ig:DataMenuItem Key="Numero" ><Template>
<asp:TextBox runat="server" ToolTip="Número" Key="NumeroP"Rows="0" Columns="0" Width="30px">1</asp:TextBox>
</Template></ig:DataMenuItem></Items></ig:WebDataMenu>