1
我想在我遇到的問題上獲得一些幫助。我有一個存儲過程返回一個數據集來填充datagriview。其中一個數據網格的列包含2個手動設置按鈕,'查看'&'添加'。這些按鈕打開一個新的彈出窗口,顯示額外的信息等。我希望能夠隱藏一個'查看'按鈕,如果1返回的參數,POCOUNT,計數等於0.即沒有什麼可以查看的行。什麼是最好的方式來實現這一點。根據存儲過程的返回值顯示/隱藏按鈕
我的存儲過程是
SELECT PM.ProjectCode,
PM.ProjectDesc,
PM.Active,
PM.Chargeable,
(SELECT COUNT(*) FROM POMaster PO WHERE PO.ProjectCode = PM.ProjectCode) AS POCount
FROM PROJECTMASTER PM
前端代碼
<asp:TemplateField HeaderText="P.O. Number" ItemStyle-Wrap="false" >
<ItemTemplate>
<asp:LinkButton ID="linkPONumber" runat="server" Text="View" CssClass="buttonStyle" OnClick="LinkPONumber_Click" CommandArgument='<%# Eval("ProjectCode") + ";" + Eval("ProjectDesc") %>' ></asp:LinkButton>
<asp:LinkButton ID="linkAddPO" runat="server" Text="Add" CssClass="buttonStyle" OnClick="LinkAddPO_Click" CommandArgument='<%# Eval("ProjectCode") + ";" + Eval("ProjectDesc") %>' ></asp:LinkButton>
</ItemTemplate>
</asp:TemplateField>
代碼隱藏
private void BindGrid()
{
DSProjectDetails = objProjectMasterBL.GetProjectDetails();
GvProject.DataSource = DSProjectDetails;
GvProject.DataBind();
}
public DataSet GetProjectDetails()
{
try
{
SqlProcedureName = "USP_GetProjectListWithPO";
SqlConnectionObject = DBConnection.InitializeConnection(SqlConnectionObject);
dsrepeater = SqlHelper.ExecuteDataset(SqlConnectionObject, CommandType.StoredProcedure, SqlProcedureName);
return dsrepeater;
}
catch (Exception ex)
{
log.Error("Exception in ProjectMasterBL.GetProjectDetails:", ex);
throw ex;
}
}
道歉,如果我發送的代碼錯誤的部分,仍然居住在noob行列
這工作出色。非常感謝你 – MollyMoo