簡體   English   中英

基礎架構網格的加載標頭

[英]loading header for infragistics grid

我有一個基礎設施網格,其中填充了選定的下拉列表。存儲的過程將列名和數據帶入2個表的結果集中。

我如何加載標題信息?

    <asp:DropDownList ID="DropDownList1" AutoPostBack="true" runat="server" OnSelectedIndexChanged="DropDownList1_SelectedIndexChanged">
   <asp:ListItem>Select Entity</asp:ListItem>
</asp:DropDownList>
<asp:Label runat="server" ID="EntityName"></asp:Label>
<ig:WebScriptManager ID="WebScriptManager1" runat="server"></ig:WebScriptManager>
<ig:WebDataGrid ID="EntityGrid" runat="server"  Width="100%" Height="50%" StyleSetName="Claymation" >

    <Behaviors>
        <ig:Sorting>
        </ig:Sorting>

    </Behaviors> 
    <ClientEvents Click="NavigateOnClick" />

</ig:WebDataGrid>   

我背后的代碼有

    protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
    {
        EntityName.Text = DropDownList1.SelectedItem.Text;
        string entity = "t_" + DropDownList1.SelectedItem.Text;
        String strConnString = ConfigurationManager.ConnectionStrings["LiveLeaseConnectionString"].ConnectionString;
        SqlConnection con = new SqlConnection(strConnString);
        SqlCommand cmd = new SqlCommand("p_DataList_ByRegardingObject", con);
        cmd.CommandType = CommandType.StoredProcedure;
        cmd.Parameters.AddWithValue("@RegardingObjectName", entity);
        SqlDataAdapter da = new SqlDataAdapter(cmd);
        DataSet ds = new DataSet();
        ds.Tables.Add("TheFirstResult");
        ds.Tables.Add("TheSecondResult");
        da.TableMappings.Add("Table", "TheFirstResult");
        da.TableMappings.Add("Table1", "TheSecondResult");

        da.Fill(ds);
        this.EntityGrid.DataSource = ds.Tables["TheSecondResult"];

        this.EntityGrid.DataBind();



    }

假設TheFirstResult表中的第一行包含列名,並且它們與實際數據的順序和編號相同,則可以執行以下操作:

for (int I = 0; I < ds.Tables["TheFirstResult"].Columns.Count; I++) {
   this.EntityGrid.Columns[I].Header.Text = ds.Tables["TheFirstResult"].Rows[0][I];
}

DataBind命令之后添加此代碼。 它將循環通過第一張表,將數據從其第一行分配到網格的列標題。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM