Click here to Skip to main content
15,907,326 members
Please Sign up or sign in to vote.
1.89/5 (2 votes)
See more:
The code of my application is shown below:

public NameList[] NavisionJobList(string UserID)
{
//logic
// return certain value
}

and in my aspx page, the code to bind the returned value to grid is:

Grid.DataSource = fetchnavisionData.NavisionJobList("Ramesh");
Grid.DataBind();

In client side the code of gridview is:
XML
<asp:GridView ID="Grid" runat="server">
          </asp:GridView>


Using this, i got all the fields as a column in gridview as expected. However i only wanted selected fields to be displayed in grid and not all fields.. How can I do it.???
in client side, I had added bound fields but that resulted to repetition of columns in grid<columns> . help me solve the issue..
Posted

C#
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
    if (e.Row.RowType == DataControlRowType.DataRow)
    {
        //here apply your condition
        if(Request.QueryString["name"] == "all")
        e.Row.Cells[<index_of_cell>].Visible = true;
        else
        e.Row.Cells[<index_of_cell>].Visible = false;
    }
}
 
Share this answer
 
i added autogeneratedcolumn and set it to true and added column field and properties manually and it worked,.,
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900