J
Jimmy
Hi all
I want to databind a dropdownlist in a datagrid:
private void Page_Load(object sender, System.EventArgs e)
{
// Put user code to initialize the page here
//SqlConnection con = new SqlConnection
SqlDataAdapter da2 = new SqlDataAdapter("select * from categories",con);
DataSet ds = new DataSet();
ds = new DataSet();
da2.Fill(ds);
DataGrid2.DataSource=ds;
DataGrid2.DataBind();
}
private void DataGrid2_ItemDataBound(object sender,
System.Web.UI.WebControls.DataGridItemEventArgs e)
{
if(e.Item.ItemType == ListItemType.AlternatingItem ||
e.Item.ItemType == ListItemType.Item)
{
SqlDataAdapter da2 = new SqlDataAdapter("select city from employees",con);
DataSet ds = new DataSet();
ds = new DataSet();
da2.Fill(ds);
DropDownList list = (DropDownList)e.Item.FindControl("ddl");
list.DataSource = ds;
list.DataBind();
}
}
Page:
<HTML>
<HEAD>
<title>WebForm1</title>
<meta name="GENERATOR" Content="Microsoft Visual Studio .NET 7.1">
<meta name="CODE_LANGUAGE" Content="C#">
<meta name="vs_defaultClientScript" content="JavaScript">
<meta name="vs_targetSchema"
content="http://schemas.microsoft.com/intellisense/ie5">
</HEAD>
<body MS_POSITIONING="GridLayout">
<form id="Form1" method="post" runat="server">
<aspataGrid id="DataGrid2" style="Z-INDEX: 101; LEFT: 64px; POSITION:
absolute; TOP: 40px" runat="server"
Height="224px" Width="392px">
<Columns>
<asp:TemplateColumn>
<ItemTemplate>
<aspropDownList ID="ddl" Runat="server"></aspropDownList>
</ItemTemplate>
</asp:TemplateColumn>
</Columns>
</aspataGrid>
</form>
</body>
</HTML>
How can it be done?
Ch Jimmy
I want to databind a dropdownlist in a datagrid:
private void Page_Load(object sender, System.EventArgs e)
{
// Put user code to initialize the page here
//SqlConnection con = new SqlConnection
SqlDataAdapter da2 = new SqlDataAdapter("select * from categories",con);
DataSet ds = new DataSet();
ds = new DataSet();
da2.Fill(ds);
DataGrid2.DataSource=ds;
DataGrid2.DataBind();
}
private void DataGrid2_ItemDataBound(object sender,
System.Web.UI.WebControls.DataGridItemEventArgs e)
{
if(e.Item.ItemType == ListItemType.AlternatingItem ||
e.Item.ItemType == ListItemType.Item)
{
SqlDataAdapter da2 = new SqlDataAdapter("select city from employees",con);
DataSet ds = new DataSet();
ds = new DataSet();
da2.Fill(ds);
DropDownList list = (DropDownList)e.Item.FindControl("ddl");
list.DataSource = ds;
list.DataBind();
}
}
Page:
<HTML>
<HEAD>
<title>WebForm1</title>
<meta name="GENERATOR" Content="Microsoft Visual Studio .NET 7.1">
<meta name="CODE_LANGUAGE" Content="C#">
<meta name="vs_defaultClientScript" content="JavaScript">
<meta name="vs_targetSchema"
content="http://schemas.microsoft.com/intellisense/ie5">
</HEAD>
<body MS_POSITIONING="GridLayout">
<form id="Form1" method="post" runat="server">
<aspataGrid id="DataGrid2" style="Z-INDEX: 101; LEFT: 64px; POSITION:
absolute; TOP: 40px" runat="server"
Height="224px" Width="392px">
<Columns>
<asp:TemplateColumn>
<ItemTemplate>
<aspropDownList ID="ddl" Runat="server"></aspropDownList>
</ItemTemplate>
</asp:TemplateColumn>
</Columns>
</aspataGrid>
</form>
</body>
</HTML>
How can it be done?
Ch Jimmy