November 14th, 2011, 04:02 PM
I have no idea why my foreach is not working.
I am fairly new to C# and I am trying to fix a bug.
and I have no idea why this foreach is not working..
protected void CQList_ItemDataBound(Object sender, DataListItemEventArgs e)
Label questionNo = (Label)e.Item.FindControl("questionNo");
Label answerNo = (Label)e.Item.FindControl("answerNo");
DataGrid answerGrid = (DataGrid)e.Item.FindControl("answerGrid");
questionNo.Text = CustomQuestionCount.ToString();
answerNo.Text = questionNo.Text;
Dictionary<uint, string> answers = new Dictionary<uint, string>();
foreach (DataRow row in CustomQuestionDS.Tables.Select("question_id=" + ((KeyValuePair<uint, string>)e.Item.DataItem).Key))
answers[MLConvert.ToUInt32(row["answer_id"])] = (String)row["answer"];
answerGrid.DataSource = answers;
It returns the data twice but with different IDs...weird, figured maybe someone can point me in the right direction and ect.
November 15th, 2011, 05:25 AM
Re: I have no idea why my foreach is not working.
Can you post sample data? Maybe there are more then one answers (good and bad) for a queastion? At first look, I cannot see anything weird.
Don't hesitate to rate my post.
- Make it run.
- Make it right.
- Make it fast.
Tags for this Thread
Click Here to Expand Forum to Full Width
This is a CodeGuru survey question.