C# - Show Data In Gridview Using Condition

May 19, 2010

I want to check a condition in a grid view e.g.

if(loginid.equels('admin'))
query = select * from memberlist;
else
query = select * from memberlist where memberid like 'operator%';

depending on the query ther grid view will display the listof members and also where to put this code in .cs or .aspx and how?

View 2 Replies


Similar Messages:

Data Controls :: Show Hide CommandButton Based On Condition In GridView

Nov 22, 2015

I am adding two button in gridview here I populate gridview on page load this work fine problem is that  when my status value are  check  or peending then my two button are show.

But I want when my status value are check then check  button  should be hide

And view button show in which row where staus value  are check But when my status value are peending here show check button and view button should be hide. I want follwing type .

Gridview Like that on page load

id name class status

1 imran 5 check

Hide Check button
View Button Show

2 ali 8 pending

Check  Button Show
View Button Hide

3 farooq 7 check

Hide Check button
View Button Show

How to do it following my code.

Default.Aspx.cs
protected void Button1_Click(object sender, EventArgs e)
{
populategridview();
}
public void populategridview()
{
string strConnString = "Data Source=.SQLEXPRESS;Integrated Security=SSPI;

[Code] .....

View 1 Replies

Forms Data Controls :: How To Show Or Hide A Template Field Within A Gridview Upon A Condition In C#

Sep 2, 2010

is there a way to show or hide a Template Field within a gridview upon a condition in C#?

View 2 Replies

Data Controls :: Show Or Hide Image Control In GridView Based On Condition From Database

Dec 19, 2012

i am using template field display image based on condition in table field. i have field name  verify i used to store yes or no value if it is yes then display image else noting to display in gridview

View 1 Replies

Data Controls :: Dynamically Show Hide Label And HyperLink Based On Condition In Same Column Of GridView

May 7, 2015

I am checking string  and then bind category. If condition is false then i  need anchor tag in which i pass querystring to specific link.

<itemtemplate>
<asp:Literal runat="server" ID="litPrice" Text='<%#((String.IsNullOrEmpty(Eval("Price").ToString()) || Eval("Price").ToString()=="00/0.00" || Eval("Price").ToString()=="0/0.00") ? "<span font-family="arial"><a href="http://www.xyz.com/web/enquiries.asp?category="+ Eval("category")>Enquiry</a></span>" : Eval("Price"))%>' >
</asp:Literal>
</itemtemplate>

I am getting error. CS1010: Newline in constant

View 1 Replies

Forms Data Controls :: Show Hyperlink On Condition In Repeater ItemTemplate

Nov 2, 2010

I have a Repeater displaying some data that doesn't do what I'd like to see. If a certain condition is met (ex: parent.NumOfChildren > 0) I would like a hyperlink shown. Here is what I have so far:

<asp:Repeater ID="parents" runat="server" >
<ItemTemplate>
<asp:HyperLink NavigateUrl='<%# "Children.aspx?parent=" &#43; DataBinder.Eval(Container.DataItem,"Parent_ID")%>'
Text='View Children' runat="server" target="_self" ID="Hyperlink2" NAME="Hyperlink2"/> -
</ItemTemplate>
</asp:Repeater>

In this case, the "View Children" link shows up for every item in my Repeater, but I'd like it shown only if parent.GetNumOfChildren() > 0. Would it be correct to try setting the Visible="true/false" property of the HyperLink? Is that the norm for this sort of problem? Or, is there a way to wrap the entire <asp:Hyperlink> ... </asp:Hyperlink> tag in an if statement that has a reference to the object that is currently being interated in the Repeater? Ie:

if(CurrentDataItemInIteration.GetNumOfChildren() > 0)
{
<asp:Hyperlink> ..... </asp:Hyperlink>
}

To me, the Visible="true/false" solution seems cleaner, if possible.

View 5 Replies

AJAX :: Show ConfirmButtonExtender Only At Some Condition

Mar 23, 2011

I want to show the confirm button extender but only at some condition after clicking the button. Is there any way to do this without using javascript ?

View 4 Replies

AJAX :: ModalPopupExtender Show Condition Not Working As Expected

May 4, 2013

I use ModalPopupExtender in my page

I have 2 imagebutton

1-Imgcab
2-imgenter

Below are my imagebuttons event code

protected void Imgcap_Click(object sender, ImageClickEventArgs e) {
string data = Server.UrlEncode(Txtbeh.Text);
SqlCommand _cmd = new SqlCommand("housepass", _cn);
_cmd.CommandType = CommandType.StoredProcedure;
_cn.Open();

[Code]....

when I click on ImgEnter it show popup menu ModalPopupExtender.Show();

It is correct problem is that when I click on imgcap if it run first ELSE condition it does Session["MessageError"] = true; and it show popupmenu (it show ModalPopupExtender)

I want it just show popup menu (ModalPopupExtender.) just when I click on imgEnter button ....

View 1 Replies

Data Controls :: How To Highlight GridView Row Based On Condition

May 25, 2012

I want to higlight the background color based on condition

E.g. I have a column like 

name       rate

rafi           100
ravi           0
karthick   300

Here rafi and karthick should display the background color

ravi should display the whitecolor

View 1 Replies

Data Controls :: Change Color Of Particular GridView Row On Some Condition?

Nov 27, 2013

There is a gridview, in that i have 5 columns. Data is coming from Database inside gridview.

I want to change the ForeColor of 5th column's particular rows in gridview according to condition.

The data in 5th column is coming from Database. I want to change the ForeColor of that column's particular rows according to condition.

here is gridview data:-

Station Name
State
Gate1
Gate2

[Code].....

I want to change the color of 5th column("DangerValue") rows only according to condition.

View 1 Replies

Data Controls :: How To Use IF ELSE Condition In EVAL Function In GridView

May 7, 2015

<asp:TemplateField HeaderText="Is Activate ?">
<ItemTemplate>
  <a href="#" onclick='fnViewRemarksTest(<%#DataBinder.Eval(Container.DataItem,"CustomerId")%>)'><%#Eval("IsActivated ")%></h3></a>
</ItemTemplate>
</asp:TemplateField>

Is Activated is a boolean data type column in Sql.

I want to Show that, when IsActivated is true text will be "User Is Active" and when false , the text will be "User Is not activate" ...

View 1 Replies

Forms Data Controls :: Binding Data With Gridview Based Upon Condition?

Jan 22, 2010

I have a Data Table which Populate from the Stored Procedure which is below

[Code]....

and iam binding the Gridview with Data Table it is working .Now i have to make some thing visible and Invisible based upon some Value like below

Datatable dtTable = (Viewstate)["StatusData"]; // Same Data Table which is Data Source of Gridview Control
[Code]....

Where Status.Open is an integer Enum value like Open = 1 and Close = 2 .row["Status"] is the Text Open and i want to compare with integer valueHow i compare the Values ? i have to use the same Data table or not?

View 2 Replies

Forms Data Controls :: Assign Dynamically Data To Gridview According To The Condition?

Nov 16, 2010

I have Gridview with column name END Date.

DATE is dd/mm/yyyy Format

Available data is :- START DATE = 1/1/2010 , STOP DATE = 1/4/2010 ,INTERVAL = 1 WEEK

HOw to bind data to gridview such that gridview should display data from 1/1/2010 to 1/4/2010 for the interval of 1week

THE OUTPUT SHOULD BE:-

[code]...

View 5 Replies

Web Forms :: Hide Show Fields In MS Reports Based On Condition?

May 22, 2012

i have passed a paramater to the report

if param="Y" then i want to display field2 else field 3

i tried that in expression as

=IIF(paramater!state.value="Y" , fields!add1.value,feilds!add2.value)

but i am not getting

View 1 Replies

Data Controls :: Condition Based Data Bind In GridView From XML

Jul 29, 2013

From my code I got all of my data from my xml database .. but I need to display only the data with match of my date. For example if i I give date as 7/25/2013 the data within the date oly want to display in grid view my c# code is

using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;

[Code] ....

My xml database is 

<?xml version="1.0" encoding="utf-8"?>
<registration>
<Date> </Date>
<Name> </Name>
<Qualification>
</Qualification>
<areaofinterest>
</areaofinterest>

[Code] ..... 

My design view code is 

<%@ Page Language="C#" MasterPageFile="~/phoenix.master" AutoEventWireup="true" CodeFile="grid1.aspx.cs" Inherits="grid1" Title="Untitled Page" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
</asp:Content> <asp:Content ID="Content2" runat="server"
contentplaceholderid="ContentPlaceHolder4">

[Code] ....

View 1 Replies

Forms Data Controls :: How To Change The Color Of The Value In Gridview Using Condition

Jun 17, 2010

[URL]

if the ABOVE pic is not visible CLICK HERE to view

I want to change the colors of the values from the table SALARY

if the salary is > 20,000 i want to change it to GREEN color

if < 20,000 then it should show RED color

View 4 Replies

Forms Data Controls :: Set Certain Columns In Gridview Invisible Upon Certain Condition?

Jul 2, 2010

I have a gridview that is being populated off of a query that has joins in it. It works fine. However, I want to display one record of all information but then blank out all colunmns accept 1 for the other 3 records that it is picking up. In other words, right now, all three records have duplicate info in them accept this one column. can this be done? Can I somehow blank out other columns based upon what is in the single column? This is all being done in a gridview. I realize it would do a master detail type scenario but I want all of this information to display without someone having to click on a field or anything.

View 4 Replies

Forms Data Controls :: Display Image In Gridview According To Condition?

May 8, 2010

I have a gridview bound to object data source & in its item template i have some labels and one image control and I have a [Status] column in database that store either true or false in bit format . now what i want is if value in status column is true then image control's ImageUrl property should use image ~/images/Show.jpg and if it have false value then it should show ~/images/Hide.jpg.

currently i am using this code it works fine but i think there must be some good better way to achieve this goal. here is the code that i m using

if (e.Row.RowType == DataControlRowType.DataRow)
{
Image img = (Image)e.Row.FindControl("ImgCatStatus");
if (img.AlternateText == "True")
{
img.ImageUrl = "~/images/Show.jpg";
}
else
{
img.ImageUrl = "~/images/Hide.jpg";
}

i have bound the alertenateurl to <%#Bind('Status')%> and performing evaluation based on value it contain

View 7 Replies

Forms Data Controls :: Hide Gridview Row Based On Condition?

May 10, 2010

I have one asp.net gridivew where i have written some code and bind it.. itz working fine now my requirment is when ever any gridview row which conatin column 3rd zero(0) i want to hide tht row ..

View 2 Replies

Data Controls :: Change GridView Row Color Based On Condition

Jul 26, 2013

I want to change the color of particular gridview rows with an image in one row, based on condtion. How to achieve it.

View 1 Replies

Data Controls :: How To Display Different Row Colors Based On Condition In Gridview

Jul 19, 2013

how to display row values based on condition in grid view control and how to display different row colors based on condition in grid view.

View 1 Replies

Data Controls :: How To Blink GridView Row Based On Some Condition Using JQuery

May 7, 2015

I have to write this code to blink particular rows of gridview based on some conditions I found below link which actually does blink but after we click the row. URL...I need that the row should blink as soon as the web page loads.I also tried using the jquery as in below link but it is also giving error as.URL...

View 1 Replies

Data Controls :: How To Change Color Of Particular Cell Of Gridview As Per Condition

Feb 25, 2016

I have a gridview that shows Gender column, My requirement is to set the color of Gender column with following condition

if Male-->Color is Red

if Female-->Color is Yellow

how should i do this ?

View 1 Replies

Data Controls :: Change Row Color Of GridView Control As Per Condition Specified

Jan 23, 2013

In my asp.net+vb web with access database in a gridview i used the following code

Sub GridView1_RowDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs)
If e.Row.RowType = DataControlRowType.DataRow Then
If (e.Row.DataItem("TEN") > 24) Then
e.Row.ForeColor = Drawing.Color.Red

[Code] ....

The above code is working in my sqldatabase web but not working in access database web...

View 1 Replies

Show/hide  the (gvChild) Based On Some Condition In Rowdatabound Event Of The GvParent?

Jun 15, 2010

I have following criteria in my gridview control.I have a parent gridview control (gvParent) which has 8columns in it. and i have gvchild within gvParent.And i want to show/hide the (gvChild) based on some condition in rowdatabound event of the gvParent. i need to display the child grid at the end of each row in gvParent .Also Child Grid should start from 3 rd column of the gvParent and should end at 8th column.How to bring the child grid after each row ?

View 2 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved