Click here to Skip to main content
15,920,217 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi guys am populating a gridview according to selected date
I get this error:DataBinding: 'System.Data.DataRowView' does not contain a property with the name 'FullName'.

this how i populate

C#
#region Load grdAvailableStaff Slots When Date Is Selected
public void loadGrdAvailableStaffSlotsWhenDateIsSelected()
{
    DataTable dt = new DataTable();
    systemBusinessLayer = new BusinessLayer();
    dt = systemBusinessLayer.grid(DatePicker.Text);
    grdAvailableStaff.DataSource = dt;
    grdAvailableStaff.DataBind();
}
#endregion

Code in my business layer

C#
public DataTable grid(string date)
{
    using (SqlConnection con = new SqlConnection(ConnString))
    {
        SqlCommand cmd = new SqlCommand("procAvailableStuff", con);
        cmd.CommandType = CommandType.StoredProcedure;
        cmd.Parameters.Add(new SqlParameter("@Date", SqlDbType.NVarChar));
        cmd.Parameters["@Date"].Value = date;
        DataTable dTable = new DataTable("Fullname");
        SqlDataAdapter adapter = new SqlDataAdapter(cmd);
        adapter.Fill(dTable);
        return dTable;
    }
}

Below is my storedprocedure

SQL
SELECT   DISTINCT  Slots.EmpRecNumber AS 'RecordNumber' ,Employee.EmpName+' '+Employee.EmpSurname AS 'EmployeeName', Slots.Timeslot, Slots.Date, Slots.SlotID,Employee.EmpEmail 
FROM         Employee INNER JOIN
                      Slots ON Employee.EmpRecNumber = Slots.EmpRecNumber
WHERE Slots.status='a' AND Slots.Date=@Date AND Slots.EmpRecNumber IN (SELECT     EmpRecNumber
FROM         Employee)
Posted
Updated 23-Sep-11 7:32am
v3

1 solution

I'm guessing you're binding to FullName in your grid, yet FullName is not a column in your query
 
Share this answer
 
Comments
Anele Ngqandu 23-Sep-11 13:39pm    
Employee.EmpName+' '+Employee.EmpSurname AS 'EmployeeName'

Ininialy I had FullName but i changed it fo EmployeeName

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900