获取错误:作业的左侧必须是变量,属性或索引器

时间:2015-05-07 06:34:14

标签: c#

我想逐个将一个数据集col值插入到另一个datset值中,但是出现了错误:赋值的左侧必须是变量,属性或索引器

i = Convert.ToInt32(dsArea.Tables[0].Rows.Count);
for (int j = 0; j <= i; j++)
{
  if (dsArea.Tables[0].Columns["AreaName"].ToString() == ds.Tables[0].Columns["AreaName"].ToString())
  {
     dsCustReg.Tables[0].Rows[j]["AreaName"].ToString() = ds.Tables[0].Rows[j]["AreaName"].ToString();
  }
}

2 个答案:

答案 0 :(得分:1)

在将ToString()分配给变量try

时,您无法使用i = Convert.ToInt32(dsArea.Tables[0].Rows.Count); for (int j = 0; j <= i; j++) { if (dsArea.Tables[0].Columns["AreaName"].ToString() == ds.Tables[0].Columns["AreaName"].ToString()) { dsCustReg.Tables[0].Rows[j]["AreaName"] = ds.Tables[0].Rows[j]["AreaName"].ToString(); } }
<div class="normal-padding">
        Quicksearch: <input type="text" id="searchBox"/>
    </div>
    <div class="ui divider"></div>
    {{#each getChildren}}
            <div class="normal-padding">
                <div class="ui two column grid">
                    <div class="column" style="width:60px;">
                        <div class="squaredOne">
                            <input type="checkbox" value="{{_id.toHexString}}" class="selectedChild" id="{{_id.toHexString}}" >
                            <label for="{{_id.toHexString}}"></label>
                        </div>
                    </div>
                    <div class="column">
                        <label for="{{_id.toHexString}}">{{firstname}} {{lastname}}</label>
                    </div>
                </div>
            </div>
    {{/each}}

答案 1 :(得分:0)

删除.ToString()

dsCustReg.Tables[0].Rows[j]["AreaName"] = ds.Tables[0].Rows[j]["AreaName"].ToString();