-1
我有一个gridview,我想添加一个按钮'VIEW',它重定向到(Customers.aspx?CustomerID=
)页面。每个客户都有一个ID,每个ID都与一个报告相关联。我不希望ID显示在我的GridView中,我希望它隐藏起来。 此外,我希望此按钮仅在用户是“管理员”或“销售人员”类别时才显示。我有一种方法可以将我的CustomerID绑定到UserCategory以分别为每个ID生成报告。查看带if else语句的按钮
我试着看看其他一些帖子,但我的按钮由于某种原因没有重定向。 有人可以帮助我找出我在这里做错了什么,或者如果我失去了一些东西。任何帮助将不胜感激。 谢谢。
<asp:TemplateField ShowHeader="False">
<ItemTemplate>
<asp:Button ID="btnView" runat="server" CausesValidation="false" CommandName="Select" Text="VIEW" />
</ItemTemplate>
<ControlStyle CssClass="button" />
</asp:TemplateField>
protected void btnView(object sender, EventArgs e)
{
Button button = (Button)sender;
GridViewRow row = (GridViewRow)button.NamingContainer;
Label lblCustomerID = (Label)row.FindControl("lblCustomerID");
txtHFUserCategory.Value = Session["UserCategoryPC"].ToString();
String strUserCat = MTProcs.GetSingleDatabaseResult("SELECT tblUsers.UserCategoryID FROM tblUsers WHERE UserID = " + txtHFUserID.Value);
if (strUserCat == "4" || strUserCat == "12")
{
ScriptManager.RegisterStartupScript(Page, typeof(Page), "OpenWindow", "window.open(Customers.aspx?CustomerID=" + lblLeadID.Text + "');", true);
}
}
如何用户和客户表在数据库链接添加Visible属性做呢? – ISHIDA
您需要加入这两个表格。否则,查询每一行的子表将不会有效。 – Win
你想在GridView中存在''吗? (即在列的单元格内),还是希望它只是在某个页面上?答案将决定您是否需要在GridView上使用'_RowDataBound()'事件处理函数,或者确实只需要页面上的if-then来显示或隐藏该按钮。 –
bradykey