タイプ datagridviewtextbox 列のグリッドビューがあります。
以下のフィールドがあります。
SrNo. | Description | HSN Code | Qty | Rate | Amount
データセットの「説明」、「HSN コード」、「数量」、「レート」のレコードを取得しました。
プログラムで「SrNo」と「Amount」を生成したい。
私のコードは次のとおりです。
int i=0;
ds = new DataSet();
ds = db.getDetailRecords(Convert.ToInt32(txtBillNo.Text));
for (i = 0; i < ds.Tables[0].Rows.Count; i++)
{
grdData.Rows[i].Cells[0].Value = i;
grdData.Rows[i].Cells[1].Value = ds.Tables[0].Rows[i]["Description"].ToString();
grdData.Rows[i].Cells[2].Value = ds.Tables[0].Rows[i]["HSNCode"].ToString();
grdData.Rows[i].Cells[3].Value = ds.Tables[0].Rows[i]["Qty"].ToString();
grdData.Rows[i].Cells[4].Value = ds.Tables[0].Rows[i]["Rate"].ToString();
grdData.Rows[i].Cells[5].Value = Convert.ToDouble(ds.Tables[0].Rows[i]["Qty"]) * Convert.ToDouble(ds.Tables[0].Rows[i]["Rate"]);
}
しかし、それは機能していません。それはエラーを与えるIndex was out of Range.
データセット値をグリッドに割り当てるにはどうすればよいですか? 助けてください。