Posted: 12/14/2011
Hello Friends,
I am making function below to get the records from a webservice of NAVISION.The code given below working fine
but the grid shows all columns and i want to show some columns.How I solve this,Please Help me to do this. I've already waste much time on this.
public void Fill_OrdDetailGrid() { List<SalesOrderWS_Filter> S_filter = new List<SalesOrderWS_Filter>(); SalesOrderWS_Filter nameFilter = new SalesOrderWS_Filter(); nameFilter.Field = SalesOrderWS_Fields.Sell_to_Customer_Name; nameFilter.Criteria = Session["user"].ToString(); S_filter.Add(nameFilter); SalesOrderWS[] list = SalesService.ReadMultiple(S_filter.ToArray(), null, 100); foreach (SalesOrderWS c in list) { grd_OrderDetails.DataSource = list; grd_OrderDetails.DataBind(); } }
Posted: 12/15/2011
Set AutogenerateColums to FALSE in your GridView and then set up some BoundField columns to display the fields that you want to show. Just make sure to set the DataField of your BoundField column to make it work.
Posted: 12/16/2011
You can also hide the unwanted columns dynamically via rowdatabound event on the code behind and set the visibility of the column. Ofcourse, if you already have a fix idea on the columns that you want to display then filtering it on the layout would be the easiest way as what Vince have mentioned.