我尝试在 grdiview 的下拉列表中添加批准类型值
网格视图
<asp:BoundField HeaderText="ApproveID" DataField="ApproveID"></asp:BoundField>
<asp:TemplateField>
<ItemTemplate>
<asp:DropDownList ID="DropDownList4" runat="server"
class="vpb_dropdown">
</asp:DropDownList>
</ItemTemplate>
</asp:TemplateField>
SQL
ALTER procedure [dbo].[viewdocid]
as
select dbo.DocumentInfo.DocID,dbo.DocumentInfo.DocName,dbo.DocumentInfo.Uploadfile,dbo.DocType.DocType,dbo.Department.DepType
from dbo.DocumentInfo left join dbo.DocType on dbo.DocumentInfo.DocTypeID=dbo.DocType.DocTypeID left join
dbo.Department on dbo.DocumentInfo.DepID=dbo.Department.DepID
C#
protected void OnRowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
//Find the DropDownList in the Row
DropDownList ddlvalue = (e.Row.FindControl("DropDownList4") as
DropDownList);
ddlvalue .DataSource = GetData("SELECT ApproveID,ApproveType FROM
ApproveType");
ddlvalue .DataTextField = "ApproveType";
ddlvalue .DataValueField = "ApproveID";
ddlvalue .DataBind();
//Add Default Item in the DropDownList
ddlvalue.Items.Insert(0, new ListItem("Please select"));
//Select the Country of Customer in DropDownList
//string country = (e.Row.FindControl("lblCountry") as Label).Text;
//ddlvalue.Items.FindByValue(country).Selected = true;
}
}
我在页面加载中添加此代码
GrdFileApprove.DataSource = dd.gdocid();
GrdFileApprove.DataBind();
由于文档表中没有批准列,这仅在批准表中。我尝试在gridview的下拉列表中显示approve.reject和pending
当我调试代码时,它显示页面加载代码中的错误..
A field or property with the name 'ApproveID' was not found on the selected data source.