24. Why do I always refresh the lower row selected by the DataGrid and scroll to the top? The selected row cannot be seen due to the relationship between the screen.
Page_load
Page. smartnavigation = true
25. modify data in the DataGrid. When you click the edit key, the data appears in the text box. How to control the size of the text box?
Private void maid (OBJ sender, maid E)
{
For (INT I = 0; I <E. Item. cells. Count-1; I ++)
If (E. Item. itemtype = listitemtype. edittype)
{
E. Item. cells [I]. Attributes. Add ("width", "80px ")
}
}
26. Dialog Box
Private Static string scriptbegin = "<script language =" JavaScript "> ";
Private Static string scriptend = "</SCRIPT> ";
Public static void confirmmessagebox (string pagetarget, string content)
{
String confirmcontent = "Var retvalue = Window. confirm ('"+ content +"'); "+" If (retvalue) {window. location = '"+ pagetarget + "';}";
Confirmcontent = scriptbegin + confirmcontent + scriptend;
Page parameterpage = (PAGE) system. Web. httpcontext. Current. Handler;
Parameterpage. registerstartupscript ("Confirm", confirmcontent );
// Response. Write (strscript );
}
27. format the time: String AA = datetime. Now. tostring ("mm DD, YYYY ");
1.1 take the current year, month, day, hour, minute, second
Currenttime = system. datetime. now;
1.2 get current year
Int year = datetime. Now. Year;
1.3 take the current month
Int month = datetime. Now. month;
1.4 get the current day
Int day = datetime. Now. Day;
1.5 current time
Int = datetime. Now. hour;
1.6 get the current score
Int = datetime. Now. minute;
1.7 takes the current second
Int second = datetime. Now. Second;
1.8 takes the current millisecond
Int millisecond = datetime. Now. millisecond;
28. Custom PagingCode:
First define the variable: public static int pagecount; // the total number of pages.
Public static int curpageindex = 1; // current page
Next page:
If (maid-1 ))
{
Datagrid1.currentpageindex + = 1;
Curpageindex + = 1;
}
BIND (); // data binding function
Previous Page:
If (maid> 0)
{
Datagrid1.currentpageindex + = 1;
Curpageindex-= 1;
}
BIND (); // data binding function
Direct page Jump:
Int A = int. parse (jumppage. value. Trim (); // jumppage. value. Trim () indicates the jump value.
If (A <datagrid1.pagecount)
{
This. Maid =;
}
BIND ();
29. Use the DataGrid:
3.1 confirm deletion:
Private void maid (Object sender, system. Web. UI. webcontrols. datagriditemeventargs E)
{
Foreach (maid di in this. Maid)
{
If (Di. itemtype = listitemtype. Item | Di. itemtype = listitemtype. alternatingitem)
{
(Linkbutton) Di. cells [8]. controls [0]). Attributes. Add ("onclick", "Return confirm ('Are you sure you want to delete this item? ');");
}
}
}