答案 0 :(得分:0)
<asp:GridView ID="OracleView" runat="server" AutoGenerateColumns="false" Width="100%" OnRowDataBound="OracleView_RowDataBound">
<Columns>
<asp:BoundField HeaderText="L id" DataField="id"></asp:BoundField>
<asp:TemplateField HeaderText="Concern">
<ItemTemplate>
<asp:DropDownList ID="ConcernList" runat="server" AutoPostBack="true" ></asp:DropDownList>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
在OracleView_RowDataBound中,您可以向
添加数据protected void OracleView_RowDataBound(object sender, GridViewRowEventArgs e)
{
string sql = "select Concern.name from Concern";
/*here your connection and method read list*/
List<string> ls = new List<string>();
ls = return your list data;
//ls.Insert(0, String.Empty);
if (e.Row.RowType == DataControlRowType.DataRow)
{
var ddl = e.Row.FindControl("ConcernList") as DropDownList;
if (ddl != null)
{
ddl.DataSource = ls;
ddl.SelectedValue = YourSelectedValueFromAnotherTable;
ddl.DataBind();
listDropdownMark = ls;
selectedMeltDropdown = YourSelectedValueFromAnotherTable;
}
}
}
很抱歉,如果我没有帮助你。