getting the label text value
-
05 Ağustos 2012 Pazar 00:48
I'm using a standard html Label. This label is in a Datagrid. I'm try to get the value using the HTMLControl To find it. I'm not having any success. I'm using the html label on purpose. Does anyone know how I can do this using my label?
Thanks
<label for="Drop" runat="server" style="font-weight: bold; display: none;">Drop</label> This label is used in a javascript on the client side.
foreach (DataGridItem di in myDataGrid.Items)
{
DropDownList ddl = (DropDownList)di.FindControl("DropDownList1");if (ddl.SelectedItem.Text.Equals("Drop"))
{
HtmlString lbl9 = (HtmlString)di.FindControl("Drop");
Label lbl9 = (Label)di.FindControl("Drop");
}
Tüm Yanıtlar
-
05 Ağustos 2012 Pazar 01:29
It sounds like you want to get the labels text on postback. If that is the case, the text is not posted back, because labels are not data entry items.Perhaps you would be able to get better advice at http://forums.asp.net, where your question is more on topic.
--
Mike- Yanıt Olarak Öneren CoolDadTxMVP, Moderator 05 Ağustos 2012 Pazar 03:09
- Yanıt Olarak İşaretleyen Lisa ZhuMicrosoft Contingent Staff, Moderator 13 Ağustos 2012 Pazartesi 10:45
-
05 Ağustos 2012 Pazar 02:49
Give the label an ID in your markup.. In the code-behind use that ID to find the control.
- Düzenleyen Steven_Schultz 05 Ağustos 2012 Pazar 02:50
-
05 Ağustos 2012 Pazar 08:48
I'm using HtmlGenericControl and I can get label value with innerText ! It's Works fine
foreach (DataGridItem di in myDataGrid.Items)
{
DropDownList ddl = (DropDownList)di.FindControl("DropDownList1");
if (ddl.SelectedItem.Text.Equals("Drop"))
{
System.Web.UI.HtmlControls.HtmlGenericControl lbl9 = (System.Web.UI.HtmlControls.HtmlGenericControl)di.FindControl("Drop");
string myLableValue = lbl9.InnerText;
}
}- Yanıt Olarak İşaretleyen Lisa ZhuMicrosoft Contingent Staff, Moderator 13 Ağustos 2012 Pazartesi 10:45