1. Add and modify the foreground code:
First, add the first three steps:
1. Front-end code: Add allowautomaticinserts = "true">
2. in <mastertableview Add: commanditemdisplay = "topandbottom"> to pop up the mode layer, add editmode = "popup"
3. Add:
<Commanditemsettings exporttow.text = "export to PDF" addnewrecordtext = "Add new project"
Refreshtext = "refresh"> </commanditemsettings>
Second, the first two steps:
1. Front-end code: Add autogenerateeditcolumn = "true" allowautomaticupdates = "true" to <telerik: radgrid Li"
2. Add
<Telerik: grideditcommandcolumn edittext = "most flexible modification">
</Telerik: grideditcommandcolumn>
Finally, if you want to modify the page that comes with radgird, the above settings are sufficient. If you want to set your own format, you should write it as follows: (this is a public method for adding and modifying :)
<Editformsettings insertcaption = "Add new data" captionformatstring = "Modify menu No.: {0 }"
Captiondatafield = "ID" editformtype = "template"
Popupsettings-modal = "true">
<Editcolumn uniquename = "editcommandcolumn1" edittext = "modify"> </editcolumn>
<Formtemplate>
<Table>
<Tr>
<TD> area_name: </TD> <TD>
<Asp: textbox id = "txtarea_name" runat = "server" text = '<% # BIND ("area_name") %>'> </ASP: textbox> </TD>
<TD> area_short </TD>
<TD>
<Asp: textbox id = "txtarea_short" runat = "server" text = '<% # BIND ("area_short") %>'> </ASP: textbox>
</TD>
</Tr>
<Tr>
<TD align = "right" colspan = "2">
<Asp: button id = "button1" text = '<% # (container is grideditforminsertitem )? "Insert": "Update" %>'
Runat = "server" commandname = '<% # (container is grideditforminsertitem )? "Cmdminsert": "Update" %> '>
</ASP: button> & nbsp;
<Asp: button id = "button2" text = "cancel" runat = "server" causesvalidation = "false" commandname = "cancel">
</ASP: button>
</TD>
</Tr>
</Table>
</Formtemplate>
<Popupsettings modal = "true"> </popupsettings>
</Editformsettings>
If you do not need any verification conditions or other prompts when adding or modifying the conditions, the above is OK. If you need to verify or manually submit the database, you can:
Protected void radgrid1_updatecommand (Object sender, gridcommandeventargs E)
{
Grideditableitem editeditem = E. item as grideditableitem;
String name = (editeditem. findcontrol ("txtarea_name") as textbox). text;
If (name = "")
{
Scriptmanager. registerstartupscript (this, GetType (), "", "alert ('name cannot be blank! ') ", True );
E. Canceled = true; // if the condition is not met, the radgird status is edit.
}
........................................ ..
The same is true for insert ....
}
Ii. Delete
1. Set autogeneratedeletecolumn = "true" allowautomaticdeletes = "true"
If you want to prompt:
Autogeneratedeletecolumn = "true" allowautomaticdeletes = "true"
<% -- Simplest and most convenient deletion -- %>
<Telerik: gridbuttoncolumn filtercontrolalttext = "filter column1 column"
TEXT = "simplest Delete" uniquename = "column1" commandname = "delete" confirmtext = "are you sure you want to delete it !? "Confirmtitle =" prompt message ">
</Telerik: gridbuttoncolumn>
Iii. Query:
If no data is found, the following message is displayed:
<Norecordstemplate>
<Div style = "color: # f00; Height: 40px; line-Height: 40px;">
<Span style = "margin-left: 10px; font-size: 14px; font-weight: bold;"> no matching record exists! </Span>
</Div>
</Norecordstemplate>
</Mastertableview>