我有一个基础网格,其中填充了选定的下拉列表。存储的过程将列名和数据带入带有 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();
}