View Full Version : Datagrid invisible Lable/Textbox does not generate HTML object?


rockdale
06-06-2006, 09:19 PM
Hi, All:

I have a datagrid with TemplateColumn as following:

<asp:TemplateColumn Visible="False" >
<ItemStyle Width="0px"></ItemStyle>
<ItemTemplate>
<asp:Label id="lblMin_Value" Visible=False runat="server" Text='<%#
DataBinder.Eval(Container, "DataItem.min_value") %>'>
</asp:Label>
</ItemTemplate>
</asp:TemplateColumn>

I set Visible = false for this column because I do not want end user
see this column. But
If I check the html source, I did not see any HTML code for this label.
If the Visble is true, on the source code of HTML, I will see <Span id
= blahblah....>. I have a client side javascript to using this label's
value (actually the span's innerText), but the HTML does not have this
<Span object, so I could get the value of this min_value.

I also tried to set Visible =FAlse for <ASP:Label , it is the same.
I tried using <ASP:textbox > it is the same, not HTML object generated.


Does anybody have experience on this before? How should I Invisible an
Label/Textbox in datagrid but generate HTML Object so that JavaScript
can access?

Thanks a lot
-Rockdale

Alvin Bruney [MVP]
06-11-2006, 05:32 PM
You'd find more specialized help in the datagrid forum for this. Basically,
you can do a findcontrol or the equivalent which is a getlementbyid to
retrieve a reference to the text box. Once the object returns a reference
you can access its properties.

--
________________________
Warm regards,
Alvin Bruney [MVP ASP.NET]

[Shameless Author plug]
Professional VSTO.NET - Wrox/Wiley
The O.W.C. Black Book with .NET
www.lulu.com/owc, Amazon
Blog: http://www.msmvps.com/blogs/alvin
-------------------------------------------------------


"rockdale" <rockdale.green@gmail.com> wrote in message
news:1149625194.071160.201220@u72g2000cwu.googlegroups.com...
> Hi, All:
>
> I have a datagrid with TemplateColumn as following:
>
> <asp:TemplateColumn Visible="False" >
> <ItemStyle Width="0px"></ItemStyle>
> <ItemTemplate>
> <asp:Label id="lblMin_Value" Visible=False runat="server" Text='<%#
> DataBinder.Eval(Container, "DataItem.min_value") %>'>
> </asp:Label>
> </ItemTemplate>
> </asp:TemplateColumn>
>
> I set Visible = false for this column because I do not want end user
> see this column. But
> If I check the html source, I did not see any HTML code for this label.
> If the Visble is true, on the source code of HTML, I will see <Span id
> = blahblah....>. I have a client side javascript to using this label's
> value (actually the span's innerText), but the HTML does not have this
> <Span object, so I could get the value of this min_value.
>
> I also tried to set Visible =FAlse for <ASP:Label , it is the same.
> I tried using <ASP:textbox > it is the same, not HTML object generated.
>
>
> Does anybody have experience on this before? How should I Invisible an
> Label/Textbox in datagrid but generate HTML Object so that JavaScript
> can access?
>
> Thanks a lot
> -Rockdale
>