Set textbox control in gridview if condition in C# ASP.NET

In my ASP.NET gridview, I have insert the Label lbannotation as default:

<asp:TemplateField HeaderText="annotation"
   ItemStyle-HorizontalAlign="Left">
   <ItemTemplate>
      <asp:Label ID="lbannotation" runat="server"
          Text='<%# Eval("tannotation").ToString() %>'
          CssClass="ddl_Class_new"></asp:Label>
  </ItemTemplate>
</asp:TemplateField>

If the string of database table column tannotation:

Eval("tannotation").ToString()

contains in our string the word ready

I need change from asp:Label

<asp:TemplateField HeaderText="annotation"
   ItemStyle-HorizontalAlign="Left">
   <ItemTemplate>
      <asp:Label ID="lbannotation" runat="server"
          Text='<%# Eval("tannotation").ToString() %>'
          CssClass="ddl_Class_new"></asp:Label>
  </ItemTemplate>
</asp:TemplateField>

to asp:TextBox

<asp:TemplateField HeaderText="annotation"
   ItemStyle-HorizontalAlign="Left">
   <ItemTemplate>
      <asp:TextBox ID="txannotation" runat="server"
          Text='<%# Eval("tannotation").ToString() %>'
          CssClass="ddl_Class_new"></asp:TextBox>
  </ItemTemplate>
</asp:TemplateField>

What should I set for this need on?

protected void gvProducts_RowDataBound(object sender, GridViewRowEventArgs e)
{
    if (e.Row.RowType == DataControlRowType.DataRow)
    {
        if (e.Row.DataItem != null)
        {
            ????
        }
    }
}

Help me to do it.



Read more here: https://stackoverflow.com/questions/65725744/set-textbox-control-in-gridview-if-condition-in-c-sharp-asp-net

Content Attribution

This content was originally published by Iter Lsic Iealf at Recent Questions - Stack Overflow, and is syndicated here via their RSS feed. You can read the original post over there.

%d bloggers like this: