Click here to Skip to main content
16,010,876 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi friends,

I have a question

my grid have column

-Name------------From-------------To-------------Rate---
Amenity 8/8/2012 8/9/2012 50.00
Amenity 8/6/2012 8/7/2012 50.00
Amenity 8/9/2012 8/10/2012 50.00
Amenity two 7/28/2012 7/31/2012 0.00
Amenity two 8/3/2012 8/4/2012 0.00

--------------------------------------------------------

now my question is this that how can i get this structure at my front end

-Name------------From-------------To-------------Rate---
Amenity 8/8/2012 8/9/2012 50.00
8/6/2012 8/7/2012 50.00
8/9/2012 8/10/2012 50.00
Amenity two 7/28/2012 7/31/2012 0.00
8/3/2012 8/4/2012 0.00

--------------------------------------------------------

the duplication in Name i just want to show it just one time

how can i do this

plz help me
Posted
Comments
prince_rumeel 6-Feb-13 10:20am    
i am using this

protected void grdHotelAmenity_RowDataBound(object sender, GridViewRowEventArgs e)
{
string strAmenityName="";
if (e.Row.RowType == DataControlRowType.DataRow)
{
strAmenityName=e.Row.Cells[0].Text;

if(strAmenityName==e.Row.Cells[0].Text)
{
//e.Row.Cells[0].Text="";
}
}
}


plz help me

You can do this on MS SQL server side with following query:
SQL
declare @table table
(
    Name varchar(20),
    [From] Date,
    [To] Date,
    Rate decimal
)

insert into @table values('Amenity', '8/8/2012', '8/9/2012', 50)
insert into @table values('Amenity', '8/6/2012', '8/7/2012', 50)
insert into @table values('Amenity', '8/9/2012', '8/10/2012', 50)
insert into @table values('Amenity two', '7/28/2012', '7/31/2012', 0)
insert into @table values('Amenity two', '8/3/2012', '8/4/2012', 0)

select
    case when number = 1 then Name else '' /*or null*/ end as Name, [From], [To], Rate
from (
    select
        row_number() over(partition by Name order by Name desc) number,
        Name, [From], [To], Rate
    from @table
) [inner]
 
Share this answer
 
Sounds like you are looking for something like: Eliminate Duplicate Values from the Grid View[^]

Check out!
 
Share this answer
 

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