Click here to Skip to main content
15,886,110 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
i want to display grid which have multiple columns ....
my code is below...it doesnot gave any error but display only one column i.e product_desc....
so plz help me to solve my problem

my code is below:-
C#
public void  get_product_group()
    {

        string product_group = "select PRODUCT_GROUP_ID,PRODUCT_GROUP_DESC FROM               QAPower.PRODUCT_GROUP";

        SqlDataAdapter sda = new SqlDataAdapter(product_group, cn);
        DataSet ds = new DataSet();
        sda.Fill(ds);
        int cnt = ds.Tables[0].Rows.Count;
        DT = ds.Tables[0];
        GrdATDataView.DataSource = ds;
        GrdATDataView.DataBind();
    }

thanks in advance...
Posted
Updated 25-Oct-12 10:40am
v2
Comments
I.explore.code 25-Oct-12 17:03pm    
can you please post the markup of your grid view?

In your aspx file make sure you have all the columns within grdview.

ASP.NET
 <columns>
                        <asp:boundfield headertext="PRODUCT_GROUP_ID" datafield="PRODUCT_GROUP_ID" sortexpression="PRODUCT_GROUP_ID" xmlns:asp="#unknown">
                             />
                        <asp:boundfield headertext="PRODUCT_GROUP_DESC" datafield="PRODUCT_GROUP_DESC" sortexpression="PRODUCT_GROUP_DESC" />
                        
</asp:boundfield></columns>



Also make sure you have not set Visible="false" for any of those columns you wanted to display.
 
Share this answer
 
I think you have AutoGenerateColumns="True" Column in your gridview and in your Query there is only two columns (PRODUCT_GROUP_ID,PRODUCT_GROUP_DESC). It's better to add your columns in your query OR if your gridview columns are AutoGenerateColumns="False" then bind your Columns in Gridview.

Thanks
 
Share this answer
 
page_load()
{
string product_group = "select * FROM QAPower.PRODUCT_GROUP";

SqlDataAdapter sda = new SqlDataAdapter(product_group, cn);
DataSet ds = new DataSet();
sda.Fill(ds,"tabname");
gridview1.datasource=ds.tables["tabname"];
gridview1.databind();

}
 
Share this answer
 
set AutoGenerateColumns="False" in gridview tag in your .aspx file.
 
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