how can I get the mark(No) for Online test?

shahab

Junior Contributor
Joined
Aug 14, 2003
Messages
206
Location
Iran(Middle East)
Hi ,there
I am simulating an Online test for a highschool!
Scenario:
In a DataGrid these three columns ->
[Question + ChoosableAnswers(A-b-C-D) + CorrectAnswer]
will bind.The third column as u know should not be apeared in an Exam session! :D ...So: TestDG.Columns[2].Visible = false ;


Important (1) :ChoosableAnswers is a DDL with 4 value(A-b-C-D)
Important (2) :CorrectAnswer is a label

Essential Problem:How can I get(Estimate) the (mark) of students for test?

I have an answer but I do not know how to programm it :confused: :-\

Code:
		private void Button2_Click(object sender, System.EventArgs e)
		{
			TestDG.Columns[2].Visible = true ;
			/*int correct = 0, wrong = 0;

			foreach (Row in DataGrid) 
			{
				if (SelectedValueODDropDownList4 == The valueof CorrectAnser InFrontof ItSelf )  
					correct++;
					  
				else 
					wrong++;				   
			}
			Response.Write(correct);
			*/
but this is not complete and it needs some change !
pic01.gif
pic02.gif
 
Last edited:
Hummm do the Web DataGrid have a TableStyle property or something like this ?

If yes... you could create one and add only the columns that you want.

And they don't..... damn...

I looked a bit at it...
you could set the option AutoGenerateColumn of the DataGrid object and maybe you could click on the link "Property Builder" in the "Description" area.

Told me if it work
 
My problem is that I don't know how can I program this part:
foreach (Row in DataGrid)
{
if (SelectedValueODDropDownList4 == The valueof CorrectAnser InFrontof ItSelf )
correct++;

else
wrong++;
}
Response.Write(correct);
I have no other problem guy!!!:)
 
foreach( Row in DataGrid ) // don't know if it's the good syntax
{
string CorrectValue = ""; // This should be recuperate from a DB instead of being set.
// you SHALL NOT put it in the Html code!!!!! (Stupid dummy error, no ?)
if( ddl4.SelectedValue == CorrectValue )
correct++;
else
wrong++;
}
 
At last I find the answer :
Code:
		private void Button2_Click(object sender, System.EventArgs e)
		{
			TestDG.Columns[2].Visible = true ;
			int correct = 0, False = 0;
			//int result = 0;
		foreach(DataGridItem dataGridItem in TestDG.Items)
			{				
			if (((DropDownList)dataGridItem.FindControl("DropDownList4")).SelectedItem.Text == dataGridItem.Cells[2].Text)
			{					
				correct++;
				result+=((DropDownList)dataGridItem.FindControl("DropDownList4"));
				Response.Write(correct+"<br>"+result);
			}
			else
				False++;
			    //result += Convert.ToInt32(dataGridItem.Cells[2].Text);		
                
			Response.Write(False+"<br>");
			}
				Response.Write(result);			
		}
But a bit problem:
Correct value is always 0! :confused:
And false value is always as the number os test!!!
Point:My Databound column answer Type in database is tinyint.
 
Back
Top