Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. instead of displaying date,how to display string in gridview?

instead of displaying date,how to display string in gridview?

Scheduled Pinned Locked Moved ASP.NET
csharpcssasp-netdatabasetutorial
1 Posts 1 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    sathyan_8294
    wrote on last edited by
    #1

    hai all, i want to display 'P' instead of date in single line in grid view. Here P means Present. i have 2 table named as employee details and attendance. emp_id and emp_name are the 2 field names for employee details table. emp_id and date1 are the 2 field names for attendance table. values in attendance table are emp_id--------date1 ---11---------10-08-2008 ---11---------11-08-2008 ---11---------12-08-2008 here datatype is datetime for date1 field. in attendance table, the date values (10-08-2008,11-08-2008,12-08-2008) are present date for emp_id 11. in output side,i select employeename as ajay from employeenamedropdownlist,then i select fromdate as 09-08-2008,then i select todate as 13-08-2008,then i finally click submit button. when i click submit button,the following output coming in grid view using my program EmployeeID--EmployeeName--09-08-2008--10-08-2008--11-08-2008--12-08-2008--13-08-2008 ---11--------------------Ajay------------------------------10-08-2008 ---11--------------------Ajay------------------------------------------------11-08-2008 ---11--------------------Ajay-------------------------------------------------------------------12-08-2008 but this output is wrong. here 2 mistake. 1st mistake: instead of 'P',displaying date in 3 lines. P means Present. 2nd mistake: Displaying 3 lines for same employeeid and employeename. so i want to display 'P' instead of date in single line in grid view as follow EmployeeID-----EmployeeName-----09-08-2008-----10-08-2008-----11-08-2008-----12-08-2008-----13-08-2008 ---11-------------------Ajay-------------------------------------------P-------------------P--------------------P how to do this? here my program using C# in asp.net protected void SubmitButton_Click(object sender, ImageClickEventArgs e) { from_date = fromdatetextbox.Text; to_date = todatetextbox.Text; emp_name = employeenamedropdownlist.SelectedValue; check(); } void check() { System.TimeSpan dt_diff = Convert.ToDateTime(to_date).Subtract(Convert.ToDateTime(from_date)); days = dt_diff.Days; for (int i = 0; i <= days; i++) { sql_date = Convert.ToDateTime(from_date).AddDays(i).ToString("MM/dd/yyyy"); da = new SqlDataAdapter("select distinct a.emp_id as EmployeeID,a.emp_name as EmployeeName,min(case when b.date1='" + sql_date + "' then b.date1 end) as '" + sql_date + "' from employeedetails as a,attendance as b where a.emp_id=b.emp_id and b.date1='" + sql_date + "' group by a.emp_id,a.emp_name", con); da.Fill(dt); } GV_musterrole.Da

    1 Reply Last reply
    0
    Reply
    • Reply as topic
    Log in to reply
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes


    • Login

    • Don't have an account? Register

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • World
    • Users
    • Groups