.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
 
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
david stephan

Home >> Forum >> ASP.Net >> Post New QuestionBookmark and Share Subscribe to Forum

Picklist: Remove Certain Items

Posted By: xack     Posted Date: May 17, 2011    Points:5   Category :ASP.Net
Hi, i'm trying a remove certain items or let me say i want to show certain items in picklist,


void BindDepartman()
{
DataTable dtTempDepartmans = Utils.GetPicklistAttributeValueKeyPair(_PortalBrandHelper.BrandProxy.BrandDedicatedCrmOrgName, "contact", "new_departman", false, "v", "t");

if (dtTempDepartmans != null && dtTempDepartmans.Rows.Count > 0)
{
ddl_departman.DataSource = dtTempDepartmans;
ddl_departman.DataTextField = "t";
ddl_departman.DataValueField = "v";
ddl_departman.DataBind();
for (int i=0; i <= 35; i++)
{
if (i == 10 || i == 26)
{
ddl_departman.Items.RemoveAt(ddl_departman.Items.IndexOf(ddl_departman.Items.FindByValue(i.ToString())));

}
}
}

}

it works fine but i've 35 items and i want to show only two of them i need a modification on this code. i need to show only 10 and 26. (yes this one is not show 10 and 26 i need reverse of this code)

Responses
Author: Maverick             
Posted Date: May 17, 2011     Points: 20   

Hello,

You need to filter your datatable i.e."dtTempDepartmans"

use the below code to filter it based on some condition of primary key

DataView view = new DataView();

view.Table = dtTempDepartmans;
view.AllowDelete = true;
view.AllowEdit = true;
view.AllowNew = true;
view.RowFilter = "City = 'Berlin'";
view.RowStateFilter = DataViewRowState.ModifiedCurrent;
view.Sort = "CompanyName DESC";
ddlDropdown.datasource=view;
Hope it helps




Thanks,
Maverick


Post Reply

You must Sign In To post reply
 
 
Find more Forum Questions on C#, ASP.Net, Vb.Net, SQL Server and more Here
Quick Links For Forum Categories:
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  OOPs  SilverlightIISJQuery
JavaScript/VBScriptBiztalkWPFPatten/PracticesWCFOthers
www.DotNetSpark.comUnAnsweredAll

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend