Rahul Lakshakar

Rahul Lakshakar

  • NA
  • 199
  • 41.6k

Access the label inside DetailsView

Apr 1 2017 2:57 AM
Hello,
 
I am trying to set the text of the label control which is inside detailsview but it's not working.
can anyone guide me please.. ??
 
My HTML Code :-
 
<asp:Panel ID="sub_question_panel" runat="server">
   <asp:DetailsView ID="DetailsView1" runat="server" CellPadding="6"    ForeColor="#333333" AutoGenerateRows="false" GridLines="None" >
   <Fields>
      <asp:TemplateField>
         <ItemTemplate>
               <table id="Question_view_table">
                  <tr>
<td style="font-family:Arial Rounded MT;">
<label id="Question_no"><span style="font-size:20px;">Question</span>:</label>
<asp:Label ID="Ques_id_label" runat="server" Text="Label"></asp:Label></td>
</tr>
<tr>
<td style="height:20px"></td>
</tr>
<tr>
<td style="font-family:'Times New Roman'; font-size:18px; ">
<label id="Question_detail"><%# Eval ("Question") %></label>
</td>
</tr>
<tr>
<td style="font-family:'Times New Roman'; font-size:18px;">
<ol style="list-style:upper-alpha">
<li>
<label id="optn1"> &nbsp&nbsp<%# Eval ("Option1") %></label></li>
<li>
<label id="optn2"> &nbsp&nbsp<%# Eval ("Option2") %></label></li>
<li>
<label id="optn3"> &nbsp&nbsp<%# Eval ("Option3") %></label></li>
<li>
<label id="optn4"> &nbsp&nbsp<%# Eval ("Option4") %></label></li>
</ol>
</td>
</tr>
            </table>
</ItemTemplate>
</asp:TemplateField>
</Fields>
</asp:DetailsView>
</asp:Panel>
 
 
 Code Behind :
 
i
protected void Page_Load(object sender, EventArgs e)
{
      int question_id = 1;
      Label Question_Id = DetailsView1.FindControl("Ques_id_label") as Label;
      Ques_id_label.Text = Convert.ToString(question_id);
 
 
 Please Help Me....
 

Answers (1)