I'm not exactly sure what you are trying to achieve. Your description is still confusing. However, if you want to only see specific items in your
DropDownList
based on some user roles, then you can do something like this:
First, you have to clear out the static items from your DropDown in your HTML markup (.aspx) like:
<asp:DropDownList ID="deptDropDownList" runat="server" AppendDataBoundItems="False" AutoPostBack="True" />
C#
var role = reader["emp_type"].ToString().ToLower();
deptDropDownList.Items.Clear();
if(role.Equals("superadmin")){
deptDropDownList.Items.Add(new ListItem("Training", "Training"));
deptDropDownList.Items.Add(new ListItem("MFGModule", "MFG Module"));
deptDropDownList.Items.Add(new ListItem("SelfLearning", "Self Learning"));
deptDropDownList.Items.Add(new ListItem("InterviewTrackingSystem", "Interview Tracking System"));
deptDropDownList.Items.Add(new ListItem("Others", "Others"));
deptDropDownList.Items.Add(new ListItem("ListOfEmployee", "List Of Employee"));
}
else if (role.Equals("trainer")){
deptDropDownList.Items.Add(new ListItem("Training", "Training"));
}
else if (role.Equals("whatever")){
}
VB
Dim role As var = reader("emp_type").ToString.ToLower
deptDropDownList.Items.Clear
If role.Equals("superadmin") Then
deptDropDownList.Items.Add(New ListItem("Training", "Training"))
deptDropDownList.Items.Add(New ListItem("MFGModule", "MFG Module"))
deptDropDownList.Items.Add(New ListItem("SelfLearning", "Self Learning"))
deptDropDownList.Items.Add(New ListItem("InterviewTrackingSystem", "Interview Tracking System"))
deptDropDownList.Items.Add(New ListItem("Others", "Others"))
deptDropDownList.Items.Add(New ListItem("ListOfEmployee", "List Of Employee"))
ElseIf role.Equals("trainer") Then
deptDropDownList.Items.Add(New ListItem("Training", "Training"))
ElseIf role.Equals("whatever") Then
End If
PS: I'm not a VB guy and just used a convert to translate C# to it's VB.NET equivalent