monkeymeister
Programmer
I am populating a drop down column in a datagrid on page load. Here is my code :
<asp:TemplateColumn>
<ItemTemplate>
<aspropDownList ID="ddlUserName" Font-Name="Verdana" Font-Size="8pt" Runat=server
DataValueField="UserName"
DataTextField="UserName"
DataSource='<%# GetUserList() %>'>
</aspropDownList>
</ItemTemplate>
</asp:TemplateColumn>
public DataSet GetUserList()
{
SqlConnection objConnection = new SqlConnection(ConfigurationSettings.AppSettings["strAtradius"]);
string strUserList = "select username from userlogin where jobrolekey = 2 ";
strUserList += "order by username";
SqlDataAdapter objDataAdapter = new SqlDataAdapter(strUserList, objConnection);
objDataAdapter.Fill(dsUsers, "Users");
return dsUsers;
}
dsUsers is global to the page. The problem I have is that the first row of the datagrid populates correctly, but the following lines append the contents of the dropdown in the row above. How do I clear the contents of the dropdown before populating each row?
Any help would be really appreciated.
Cheers,
Mike
<asp:TemplateColumn>
<ItemTemplate>
<aspropDownList ID="ddlUserName" Font-Name="Verdana" Font-Size="8pt" Runat=server
DataValueField="UserName"
DataTextField="UserName"
DataSource='<%# GetUserList() %>'>
</aspropDownList>
</ItemTemplate>
</asp:TemplateColumn>
public DataSet GetUserList()
{
SqlConnection objConnection = new SqlConnection(ConfigurationSettings.AppSettings["strAtradius"]);
string strUserList = "select username from userlogin where jobrolekey = 2 ";
strUserList += "order by username";
SqlDataAdapter objDataAdapter = new SqlDataAdapter(strUserList, objConnection);
objDataAdapter.Fill(dsUsers, "Users");
return dsUsers;
}
dsUsers is global to the page. The problem I have is that the first row of the datagrid populates correctly, but the following lines append the contents of the dropdown in the row above. How do I clear the contents of the dropdown before populating each row?
Any help would be really appreciated.
Cheers,
Mike