1 First we need to add other third party .dll file
Koutny.WebControls.DropDownGroupableList.Net2.dll
2 Then we need to include this in our project
we do this by adding this Koutny.WebControls.DropDownGroupableList.Net2.dll file in bin and adding inleft side toolbox
3 after this include this in web config file
<authentication mode="Windows"/>
<pages>
<controls>
<add tagPrefix="koutny" namespace="Koutny.Web.UI.WebControls" assembly="Koutny.WebControls.DropDownGroupableList.Net2"/>
<add tagPrefix="asp" namespace="System.Web.UI" assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
<add tagPrefix="asp" namespace="System.Web.UI.WebControls" assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/></controls>
<namespaces>
<add namespace="Koutny.Web.UI.WebControls"/>
</namespaces>
</pages>
4 after that use the control in design page like this
<koutny:DropDownGroupableList ID="drop1" runat="server" CssClass="select" Width="150px" >
<koutny:OptionListItem Text="Select Category"/>
</koutny:DropDownGroupableList>
5 and in code behind
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
drop1.Items.AddItem("Item1");
drop1.Items.AddItem("Item2");
drop1.Items.AddGroup("Group1", "G1");
drop1.Items.AddItem("Item3", "Item3", "G1");
drop1.Items.AddItem("Item4", "Item4", "G1");
drop1.Items.AddItem("Item5");
}
}
6. to get the value of the selected item use like this
protected void DisplaySelectedItem(object sender, EventArgs e)
{
OptionListItem selectedItem = drop1.SelectedItem;
if (selectedItem != null)
{
litSelectedItem.Text = selectedItem.Text;
OptionGroupItem selectedGroup = drop1.SelectedGroup;
if (selectedGroup != null) litSelectedGroup.Text = selectedGroup.Text;
else litSelectedGroup.Text = "none";
}
}
Koutny.WebControls.DropDownGroupableList.Net2.dll
2 Then we need to include this in our project
we do this by adding this Koutny.WebControls.DropDownGroupableList.Net2.dll file in bin and adding inleft side toolbox
3 after this include this in web config file
<authentication mode="Windows"/>
<pages>
<controls>
<add tagPrefix="koutny" namespace="Koutny.Web.UI.WebControls" assembly="Koutny.WebControls.DropDownGroupableList.Net2"/>
<add tagPrefix="asp" namespace="System.Web.UI" assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
<add tagPrefix="asp" namespace="System.Web.UI.WebControls" assembly="System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/></controls>
<namespaces>
<add namespace="Koutny.Web.UI.WebControls"/>
</namespaces>
</pages>
4 after that use the control in design page like this
<koutny:DropDownGroupableList ID="drop1" runat="server" CssClass="select" Width="150px" >
<koutny:OptionListItem Text="Select Category"/>
</koutny:DropDownGroupableList>
5 and in code behind
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
drop1.Items.AddItem("Item1");
drop1.Items.AddItem("Item2");
drop1.Items.AddGroup("Group1", "G1");
drop1.Items.AddItem("Item3", "Item3", "G1");
drop1.Items.AddItem("Item4", "Item4", "G1");
drop1.Items.AddItem("Item5");
}
}
6. to get the value of the selected item use like this
protected void DisplaySelectedItem(object sender, EventArgs e)
{
OptionListItem selectedItem = drop1.SelectedItem;
if (selectedItem != null)
{
litSelectedItem.Text = selectedItem.Text;
OptionGroupItem selectedGroup = drop1.SelectedGroup;
if (selectedGroup != null) litSelectedGroup.Text = selectedGroup.Text;
else litSelectedGroup.Text = "none";
}
}
No comments:
Post a Comment