Click here to Skip to main content
15,889,843 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i have the one table in data base side...its having 8 column field.in that table having only 5 column value.. and other column value is zero.

when ever am load Default.aspx page that time value fields are visible true.other Zero column value hide or visible false how to write code..please help...
Posted
Comments
Naveen Kumar Tiwari 20-Feb-15 23:41pm    
according to your question. i think if you want to show only 5 column values then bind only required column in grid view what value you want to show..if other things pleas elaborate more.. thanks
Karthic Raja 21-Feb-15 0:39am    
id Val1 Val2 Val3 Val4 Val5 Val6 Val7 Val8
1 1000 1500 0 750 0 250 2000 0


In that table output display grid view only.

Am Execute the query Select * from table_name


The condition is Zero column field Header Template is visible false. When ever am insert the value in Val3,Val5,Val8

that time that header template shown(Visible true)...how to solve this one...

Grid view Output:
Only Display(i need That Select * from tablename Not select Val1 Val2 Val4 Val6) Val7

id Val1 Val2 Val4 Val6 Val7
1 1000 1500 750 250 2000

Just select those five columns that have value (say col1 to col5) using sql, e.g.
select col1, col2, col3, col4, col5 from tablename
 
Share this answer
 
Here's a sample Code for you
Hope this help.........

C#
protected void GridView1_RowCreated(object sender, GridViewRowEventArgs e)
  {
      if (<YOUR CONDITION GOES HERE>)
      {
      GridView1.Columns[0].Visible = false; // just change the index of Columns to where your Template column resides
      }
  }

Happy Coding.........
 
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