TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Prakash Mondal
NA
288
208.9k
How to hide GridView Rows with conditions in ASP.NET C#?
Mar 25 2014 3:20 PM
I want to hide selected day rows in gridview.
database table:
Design View (Default2.aspx):
Source View:
<td>
<asp:Button ID="Button1" runat="server" Text="Show" Font-Bold="True"
onclick="Button1_Click" />
</td>
<td>
</td>
<td>
</td>
</tr>
<tr>
<td>
</td>
<td colspan="2">
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False">
<Columns>
<asp:TemplateField HeaderText="Selection">
<ItemTemplate>
<asp:CheckBox ID="CheckBox1" runat="server" />
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Days">
<ItemTemplate>
<asp:Label ID="Label1" runat="server" Text='<%#Eval("DayName") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Time">
<ItemTemplate>
<br />
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
</td>
Code View( Default.aspx.cs):
protected void Button1_Click(object sender, EventArgs e)
{
String[] arr = new String[6];
arr[0] = "Wednesday";
arr[1] = "Friday";
arr[2] = "Saturday";
SqlConnection con = new SqlConnection("Data Source=.\\SQLEXPRESS;AttachDbFilename=|DataDirectory|\\TestDB.mdf;Integrated Security=True;Connect Timeout=30;User Instance=True");
SqlCommand cmd = new SqlCommand();
SqlDataReader dr;
DataTable DT = new DataTable();
try
{
con.Open();
SqlDataAdapter da = new SqlDataAdapter("select *from day", con);
da.Fill(DT);
GridView1.DataSource = DT;
GridView1.DataBind();
}
catch (Exception pm)
{
}
finally
{
con.Close();
}
}
Output:
But I want to hide those rows which I selected pink background array values.
i.e,
String[] arr = new String[6];
arr[0] = "Wednesday";
arr[1] = "Friday";
arr[2] = "Saturday";
So, only show Monday, Tuesday, Thursday, Sunday rows in gridview.
Please Help Me.
Reply
Answers (
5
)
how to track user information (pages he visited, task perfor
How to display product offers from database on image ?