我嘗試添加在下拉列表批准類型值grdiview與名稱的字段或屬性「ApproveID」未選擇的數據源
的GridView
<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();
地方,因爲在文件表中沒有approveid列,這是隻有在審批表中添加該代碼。 我試圖說明approve.reject和GridView控件在下拉列表未決
當我調試代碼它告訴我在頁面加載代碼錯誤..
A field or property with the name 'ApproveID' was not found on the selected data source.
我嘗試烏爾查詢它讓我錯誤 –
不正確synatx錯誤附近「ApproveType」 –
見我的答案更新.. –