Hi nedash,
Refer the below sample.
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" OnRowDataBound="OnRowDataBound">
<Columns>
<asp:TemplateField HeaderText="Id">
<ItemTemplate>
<asp:Label ID="lblId" runat="server" Text='<%# Bind("Id") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="sefaresh">
<ItemTemplate>
<asp:Label ID="lblSefaresh" runat="server" Text='<%# Bind("sefaresh") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Peygiri Code">
<ItemTemplate>
<asp:HyperLink ID="HyperLink1" runat="server" NavigateUrl='<%# "ViewSendOrder.aspx?PeygiriCode=" + Eval("PeygiriCode") %>'>ارسال شده</asp:HyperLink>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
protected void Page_Load(object sender, EventArgs e)
{
if (!this.IsPostBack)
{
DataTable dt = new DataTable();
dt.Columns.AddRange(new DataColumn[3] { new DataColumn("Id", typeof(int)),
new DataColumn("PeygiriCode", typeof(string)), new DataColumn("sefaresh", typeof(string)) });
dt.Rows.Add(1, "12345", "ارسال");
GridView1.DataSource = dt;
GridView1.DataBind();
}
}
protected void OnRowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
if ((e.Row.FindControl("lblSefaresh") as Label).Text.Trim() == "ارسال")
{
GridView1.Columns[2].Visible = false;
}
}
}
Output