Click here to Skip to main content
15,889,216 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi All,
I have got small doubt
My dataset has three fields like: ID, NAME, and Points

I have to bind this dataset to Gridview. My problem is that I have to display only two fields to the end user (NAME and Points). Can I bind my dataset to the Gridview in this scenario????

Thanks
Posted
Updated 2-Nov-10 23:12pm
v2

Sure, just set visibility for the ID-column to false.
 
Share this answer
 
SqlDataAdapter adap = new SqlDataAdapter("select * from tablename", con);
con.Open();
DataSet ds = new DataSet();
adap.Fill(ds);
GridView1.DataSource = ds;
GridView1.DataBind();
con.Close();

and in design view use as:
<asp:gridview id="GridView1" autogeneratecolumns="false" runat="server" >
<columns> <asp:boundfield datafield="NAME" headertext="NAME">
<asp:boundfield datafield="Points" headertext="Points">
 
Share this answer
 
v3
Hi.
select ID column and then visible = false.
or you can use of:

C#
dataGridView1.Columns["id"].Visible = false;
 
Share this answer
 
v2

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