如何从结果集中获取实际值而不是 "System.Data.DataRow"?

How can I get the actual value from the result set rather than "System.Data.DataRow"?

我有这段代码可以从包含查询结果的 table 中获取结果:

For i As Integer = 0 To categoryDT.Rows.Count-1
    Dim coName = New Label()
    coName.Text = categoryDT.Rows(i).ToString()
    formCustCatMaint.Controls.Add(coName)
    Dim chk = New CheckBox()
    chk.ID = "chk." + i.ToString()
    formCustCatMaint.Controls.Add(chk)
Next

不幸的是,添加到页面的是正确数量的复选框,但所有复选框都在相应标签中装饰有相同的值。根据需要,标签的文本不是来自 table 的值,而是 "System.Data.DataRow"。

分配 table 行的内容还需要什么,而不仅仅是数据的一般类型?

您需要使用列名或列索引从数据行中获取实际值。

coName.Text = categoryDT.Rows(i)(1).ToString();
//here 1 is just a sample value. You need to put the zero based index of column whose value you want to display.