41. Determine if it is a number/** // <summary>
/// Name: IsNumberic
/// Function: determines whether the input is a number.
/// Parameter: string oText: Source Text
/// Return value: bool true: false: No
/// </Summary>
Public bool IsNumberic (string oText)
{
Try
{
Int var1 = Convert. ToInt32 (oText );
Return true;
}
Catch
{
Return false;
}
}
Obtain the actual length of a string (including Chinese characters)
// Obtain the actual length of the string oString
Public int StringLength (string oString)
{
Byte [] strArray = System. Text. Encoding. Default. GetBytes (oString );
Int res = strArray. Length;
Return res;
}
42. Convert the carriage return to the TAB. // when you press the carriage return button on the control with the keydown event, it becomes the tab.
Public void Tab (System. Web. UI. WebControls. WebControl webcontrol)
{
Webcontrol. Attributes. Add ("onkeydown", "if (event. keyCode = 13) event. keyCode = 9 ");
}
43. If the index public void jumppage (System. Web. UI. WebControls. datagrid dg) is exceeded when the page of the DataGrid is deleted)
{
Int int_PageLess; // defines the number of page jumps
// If the current page is the last page
If (dg. CurrentPageIndex = dg. The PageCount-1)
{
// If there is only one page
If (dg. CurrentPageIndex = 0)
{
// After deletion, the page is displayed on the current page.
Dg. CurrentPageIndex = dg. The PageCount-1;
}
Else
{
// If the last page contains only one record
If (dg. Items. Count % dg. PageSize = 1) | dg. PageSize = 1)
{
// After deleting the last record of the last page, the page should jump to the previous page
Int_PageLess = 2;
}
Else // if the number of records on the last page is greater than 1, the records are still on the current page after the last page is deleted.
{
Int_PageLess = 1;
}
Dg. CurrentPageIndex = dg. PageCount-int_PageLess;
}
}
}