KyLim KyLim - 13 days ago 7
C# Question

Number looping get row number(01,02,03)

string[] SName = Request.Form.GetValues("Description");
string[] Email = Request.Form.GetValues("Email");
DataTable dtable = dt();
for (int i = 0; i <= SName.Length - 1; i++)
{
DataRow row1 = dtable.NewRow();
row1["Description"] = SName[i];
row1["Email"] = Email[i];
DAL.DMSS insertdata = new DMSS();
insertdata.INSERT_DATA(loggeduser.SUBSIDIARY_CD, input, SName[i], Email[i]);
}


above are my code to get the data from dynamic row add.
if i have 2 rows,data i get is :

enter image description here

now i want to add 1 more data ,sequence number

enter image description here

tried this code but not working..

for (int i = 0; i <= SName.Length - 1; i++)
{
if (i.length <2 )
{
string strvalue = i.PadLeft(2, '0');
}
else
{
string strvalue = i;
}

DataRow row1 = dtable.NewRow();
row1["Description"] = SName[i];
row1["Email"] = Email[i];
DAL.DMSS insertdata = new DMSS();
insertdata.INSERT_DATA(loggeduser.SUBSIDIARY_CD, input, SName[i], Email[i], strvalue);
}

Answer
        for (int i = 0; i <= SName.Length - 1; i++)
        {
            var rowNumber = (i + 1).ToString("0#");
        }
Comments