Firstly, I have 3 tables in my database:
Student |
---|
StudentID |
Name |
Adress |
OtherInfo |
TuitionFee |
---|
StudentID |
Years |
Semester |
FeeAmount |
Detailed_TuitionFee |
---|
StudentID |
Years |
Semester |
PaymentDate |
PaymentAmount |
Then I created a stored procedure to select some column on [TuitionFee ]
and [Detailed_TuitionFee ]
with StudentID
as parameter.
create procedure
@StudentID
as
begin
select
from [TuitionFee ]
left outer join [Detailed_TuitionFee ] on TuitionFee.StudentID = Detailed_TuitionFee.StudentID
and TuitionFee.Semester = Detailed_TuitionFee.Semester
where TuitionFee.StudentID = @StudentID
and Detailed_TuitionFee.StudentID = @StudentID
In C#, the code I wrote is
BindingSource bdsTuitionInfo = new BindingSource();
String studentID;
GridControl gCtrlTuition;
GridView gViewTuition;
String sqlCmd = "exec Stored procedure" studentID;
DataTable dt = Program.ExecSqlDataTable(sqlCmd); // create a Data table from SP
bdsTuitionInfo.DataSource = dt; // import data table into Binding source
gCtrlTuition.DataSource = bdsTuitionInfo; // import Binding source into Grid Control
gViewTuition.DataSource = bdsTuitionInfo; // The code shows ERROR: "Property or indexer 'property' cannot be assigned to -- it is read only" here
How do I show the data from this BindingSource
in the GridView
?
Is there anything to adjust or configure in my GridView
?
CodePudding user response: