Loading ...

Want to show some field of list in grid

Who is online?  0 guests and 0 members
home  »  forums   »  asp.net topics   »  web forms / data controls   » Want to show some field of list in grid

Want to show some field of list in grid

Posts under the topic: Want to show some field of list in grid

Posted: 12/14/2011

Lurker 5  points  Lurker
  • Joined on: 12/14/2011
  • Posts: 1

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

Professional 8338  points  Professional
  • Joined on: 4/15/2009
  • Posts: 424
  Answered

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

Lurker 65  points  Lurker
  • Joined on: 12/16/2011
  • Posts: 9
  Answered

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.


Page 1 of 1 (3 items)