ASPX -
<asp:TemplateField HeaderText="Publish">
<ItemTemplate>
<asp:Label ID="lblStatus" Text='<%# Eval("Status") %>' runat="server" Visible="false"></asp:Label>
<asp:LinkButton ID="linkpublishQues" runat="server" CommandArgument='<%#Eval("QuestionId")%>'
CommandName="Publish" OnClientClick="return confirm('Do you want to publish this question?')">Publish</asp:LinkButton>
<asp:LinkButton ID="linkunpublishQues" runat="server" CommandArgument='<%#Eval("QuestionId")%>'
CommandName="UnPublish" OnClientClick="return confirm('Do you want to unpublish this question?')">UnPublish</asp:LinkButton>
</ItemTemplate>
</asp:TemplateField>
.CS -
Label lblStatus = e.Row.FindControl("lblStatus") as Label;
if (lblStatus.Text == "Save")
{
LinkButton linkunpublishQues = (LinkButton)e.Row.FindControl("linkunpublishQues");
LinkButton linkpublishQues = (LinkButton)e.Row.FindControl("linkpublishQues");
linkunpublishQues.Visible = false;
linkpublishQues.Visible = true;
}
else if (lblStatus.Text == "Publish")
{
LinkButton linkunpublishQues = (LinkButton)e.Row.FindControl("linkunpublishQues");
LinkButton linkpublishQues = (LinkButton)e.Row.FindControl("linkpublishQues");
linkunpublishQues.Visible = true;
linkpublishQues.Visible = false;
}
<asp:TemplateField HeaderText="Publish">
<ItemTemplate>
<asp:Label ID="lblStatus" Text='<%# Eval("Status") %>' runat="server" Visible="false"></asp:Label>
<asp:LinkButton ID="linkpublishQues" runat="server" CommandArgument='<%#Eval("QuestionId")%>'
CommandName="Publish" OnClientClick="return confirm('Do you want to publish this question?')">Publish</asp:LinkButton>
<asp:LinkButton ID="linkunpublishQues" runat="server" CommandArgument='<%#Eval("QuestionId")%>'
CommandName="UnPublish" OnClientClick="return confirm('Do you want to unpublish this question?')">UnPublish</asp:LinkButton>
</ItemTemplate>
</asp:TemplateField>
.CS -
Label lblStatus = e.Row.FindControl("lblStatus") as Label;
if (lblStatus.Text == "Save")
{
LinkButton linkunpublishQues = (LinkButton)e.Row.FindControl("linkunpublishQues");
LinkButton linkpublishQues = (LinkButton)e.Row.FindControl("linkpublishQues");
linkunpublishQues.Visible = false;
linkpublishQues.Visible = true;
}
else if (lblStatus.Text == "Publish")
{
LinkButton linkunpublishQues = (LinkButton)e.Row.FindControl("linkunpublishQues");
LinkButton linkpublishQues = (LinkButton)e.Row.FindControl("linkpublishQues");
linkunpublishQues.Visible = true;
linkpublishQues.Visible = false;
}
No comments:
Post a Comment