如何创建像Oracle表格形式的ASP.Net表单?

时间:2017-10-10 04:50:35

标签: c# sql asp.net sql-server

任何人都可以给我一些关于如何创建像Oracle表格形式的ASP.NET表单的想法。

就像我在下面附上的那样。 enter image description here

1 个答案:

答案 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;
            }

        }

    }

很抱歉,如果我没有帮助你。