how to form a 3 digit code after a user enters some value in a textbox asp.net C#
I want to first form a 3-digit code once a user enters some input in a textbox.
I have a database table that has the text value that is to be entered in a 开发者_如何学运维text box for these text values there is corresponding numeric value which ranges from 3-999.
suppose user enters 'asd' and corresponding value in the database table is 9 (both 'asd' and '9'should be compared in the database table) than i want a 3-digit number to be formed as '009'.
Similarly there are other controls such as DropDownList and other textboxes from which the user input must be read and converted to a particular numeric code and thus finally forming a 14 digit code.
How can i achieve this. I want to know the way i should proceed with this. I am very new to programming.
First get the data table from the database and hold it into the data table Then when the user write/select some values from the controls then call following method and pass the DataTable and the user Input. CompareItems Method will Return you the corresponding value of the UserInput. Add your login for creating 3 digit number.
string spclDigit="";
private void CompareItems(DataTable dbTable, string value)
{
for (int j = 0; j < dbTable.Rows.Count; j++)
{
//In the Below
if (dbTable.Rows[j]["ColumnName"].ToString() == value)
{
string newCorrspndngValue= dbTable.Rows[j]["ColumnName"].ToString();
//Generate the 3 Digit No Here.
spclDigit=spclDigit +//Add ur logic to Generate the 3 digit number
}
}
}
精彩评论