I am making an application that generates 'ID'
automatically. Let me post part of my code for ya all.
Expand|Select|Wrap|Line Numbers
- dt = dB1DataSet1.Tables["company"];
- len = dt.Rows.Count + 1;
- dr = dt.Rows[len];
- code = dr["C_ID"].ToString();
- cde = code.Substring(1, 2);
- ctr = Convert.ToInt32(cde);
- if ((ctr >= 1) && (ctr < 9))
- {
- ctr = ctr + 1;
- textBox1.Text = "C00" + ctr;
- }
- else if ((ctr >= 9) && (ctr < 99))
- {
- ctr = ctr + 1;
- textBox1.Text = "C0" + ctr;
- }
- else if (ctr >= 99)
- {
- ctr = ctr + 1;
- textBox1.Text = "C" + ctr;
- }
here company is table where i have C_ID column.
Every time i try to run this code it gives me error
in line : dr = dt.Rows[len] Error : "Make sure that maximum index on the list is less than the list size".
And also the 'ID' that is getting generated is not being displayed in text box. So do have any suggestions about how do i do it?
Thanks
ajinkya