instead of displaying date,how to display string in gridview?
-
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