Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <blockquote> <p>what is the difference between this label text type ?</p> </blockquote> <pre><code>&lt;asp:Label ID="lbl2" **Text="Name"** runat="server"&gt;&lt;/asp:Label&gt; </code></pre> <p>will create a <code>Label</code> control which <code>Text</code> property will have the value "Name"</p> <pre><code>&lt;asp:Label ID="lbl2" runat="server"**&gt;Name&lt;/**asp:Label&gt; </code></pre> <p>will create a <code>Label</code> control </p> <ul> <li>with <code>Text</code> property having the value <code>String.Empty</code></li> <li>with a <code>Literal</code> child control which <code>Text</code> property value will be "Name"</li> </ul> <p>be aware that using both behaviors (setting <code>Text</code> property and having content) at the same time might lead to unexpected behavior : see <a href="http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.label.text.aspx" rel="noreferrer">http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.label.text.aspx</a> </p> <blockquote> <p><strong>Note</strong> : Setting the Text property will clear any other controls contained in the Label control.</p> </blockquote> <p>So I think the problem is that when you write :</p> <pre><code>&lt;asp:Label ID="lbl2" runat="server"**&gt;&lt;%# Eval("StudentName") %&gt;&lt;/**asp:Label&gt; </code></pre> <p>then </p> <pre><code>Label xx = GridView1.Rows[e.NewEditIndex].FindControl("lbl2") as Label; txtName.Text = xx.Text; </code></pre> <p>You are trying to access value of a child Literal control which has not yet been DataBound</p> <p>Not sure it would work or make a difference, but you may try :</p> <pre><code>Label xx = GridView1.Rows[e.NewEditIndex].FindControl("lbl2") as Label; xx.Controls[0].DataBind(); txtName.Text = xx.Text; </code></pre> <p>Anyway, by now you should have figured that you'd better use the Text property of your Label and not the implicit Text Literal</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload