Hello
I want Hide Column Of GridView According To condition and show again that column
Suppose Their are 10 column and I want show only 5 then only 5 are shown
Hello
I want Hide Column Of GridView According To condition and show again that column
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Sumit JoshiRank #1,252 · 1.4K reputationPosted Aug 21, 2015, 1:12 AM EDT
function hideColumn()
{
col_num = document.getElementById("column_numbder").value;
rows = document.getElementById("myGridView").rows;
for(i=0;i
rows[i].cells[col_num].style.display="none";
}
}
script>
If you want to hide Column (say column no. 1) then the following code will work like a breeze [<:o)]
Vaikesh K PRank #808 · 2.8K reputationPosted Aug 21, 2015, 1:37 AM EDT
using System; using System.Data; using System.Windows.Forms; using System.Data.SqlClient; namespace WindowsApplication1 { public partial class Form1 : Form { public Form1() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { dataGridView1.ColumnCount = 3; dataGridView1.Columns[0].Name = "Product ID"; dataGridView1.Columns[1].Name = "Product Name"; dataGridView1.Columns[2].Name = "Product Price"; string[] row = new string[] { "1", "Product 1", "1000" }; dataGridView1.Rows.Add(row); row = new string[] { "2", "Product 2", "2000" }; dataGridView1.Rows.Add(row); row = new string[] { "3", "Product 3", "3000" }; dataGridView1.Rows.Add(row); row = new string[] { "4", "Product 4", "4000" }; dataGridView1.Rows.Add(row); dataGridView1.Columns[1].Visible = false; dataGridView1.Rows[1].Visible = false; } } }Chandrakant Patil124 reputationPosted Aug 21, 2015, 1:58 AM EDT