locked
/?\ How to access controls used inside listview /?\ RRS feed

  • Question

  • User-1425286219 posted

    Hi friends, i have a listview control inside which in "LayoutTemplate" part i have a label control i.e. "lblques". Now at the page load event of this page in which listview control is residing, i've to assign some values to the label "lblques". Can any one help me how to acheive it

    <LayoutTemplate>
    <h2>Answers</h2>
    <asp:Label ID="lblques" runat="server"></asp:Label>
    <br />
    <div id="itemPlaceholder" runat="server">
    </div>
    </LayoutTemplate>

    remember i don't have to access it's value. I want to change its text property through load event of a page.

    Thursday, March 10, 2011 5:23 AM

Answers

  • User-1423995609 posted

    I think you can't change it in Page_Load, because in that stage Label doesn't have any value, you should consider to change it in DataBound event.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, March 10, 2011 8:46 AM
  • User398667345 posted

    try this

    ((Labe)YourListViewID.FindControl("lblques")).Text = "Your Custom Value";

    enjoy...

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, March 10, 2011 9:29 AM

All replies

  • User-1423995609 posted

    I think you can't change it in Page_Load, because in that stage Label doesn't have any value, you should consider to change it in DataBound event.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, March 10, 2011 8:46 AM
  • User398667345 posted

    try this

    ((Labe)YourListViewID.FindControl("lblques")).Text = "Your Custom Value";

    enjoy...

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, March 10, 2011 9:29 AM