1. Add a confirmation prompt to the delete button:
Foreground method: onclientclick = "return window. Confirm ('Are you sure you want to delete it? ')"
Background method: btndelete. Attributes. Add ("onclick", "Return confirm ('Are you sure you want to delete it? ');");
2. Values in Dataset:
Lbltitle. Text = Ds. Tables [0]. Rows [0] ["title"]. tostring ();
3. String truncation method:
Public String stringformat (INT Len, string Str)
{
Return (Str. length> Len )? Str. substring (0, Len) + "...": STR;
}
4. Obtain the control in the gridview in the gridview event:
Linkbutton lbtnmanager = E. Row. findcontrol ("lbtnmanager") as linkbutton;
5. Obtain the ID of the primary key in datakeynames of the gridview:
Int id = convert. toint32 (sender as gridview). datakeys [E. Row. rowindex]. value. tostring ());
6. viewstate application:
[Disable viewstate at the front-end of the website; of course, it is best not to use PostBack]
Public String vsename
{
Get
{
If (enableviewstate)
{
Object OBJ = viewstate ["ename"];
If (OBJ! = NULL)
Return (string) OBJ;
Else
Return string. empty;
}
Else
Return string. empty;
}
Set