An edit, cancel feature script that implements the DataGrid [No Refresh]

Source: Internet
Author: User
Tags implement
datagrid| Script | refresh | no refresh
A script to implement the "edit" and "Cancel" function of the DataGrid, with the aim of not generating page refreshes select from Brownyu Blog
Keyword section implements the "edit", "Cancel" feature script for the DataGrid, with the aim of not generating page refreshes
Source

A script to implement the "edit" and "Cancel" feature of the DataGrid, with the aim of not generating page refreshes
<script language= "JavaScript" >
var selectrow= "";
var SelectObject;
function Editcell (thisobject,type)
{
var id = thisobject.id;
var buttonid= "button" +type;
var row=id.replace (ButtonID, "");
if (type==1&&selectrow.length>0&&selectobject!=null)
{
Editrow (Selectrow,2,selectobject);
Selectrow= "";
}
if (type==1) {selectrow=row;selectobject=thisobject;} Else{selectrow= ""; selectobject=null;}
Editrow (Row,type,thisobject);
}

function Editrow (row,type,thisobject)
{
var visible1= "None";
var visible2= "inline";
if (type!=1)
{
visible1= "inline";
Visible2= "None";
}
var buttonid= "button" +type;
var style;
var i;
for (i=1;i<8;i++)
{
var name1=row+ "Img" +i;
Document.all[name1].getattribute ("style"). Display=visible1;
name1=row+ "Text" +i;
var name2=row+ "Checkbox" +i;
Document.all[name2].getattribute ("style"). Display=visible2;
if (type!=1)
{
if (document.all[name1].value==1)
Document.all[name2].checked=true;
Else
Document.all[name2].checked=false;
}
}

var tdindex = ThisObject.parentElement.cellIndex;
if (type>1) Tdindex = tdIndex-1;
Thisobject.parentelement.parentelement.cells[tdindex].getattribute ("style"). Display=visible2;

Thisobject.parentelement.colspan=type;

var name;
Name=row+buttonid;
Document.all[name].getattribute ("style"). display= "None";

if (type==1)
{
Document.all[name].parentelement.parentelement.getattribute ("style"). backgroundcolor= "LightYellow";
name=row+ "Button2";
Document.all[name].getattribute ("style"). display= "inline";
}
Else
{
Document.all[name].parentelement.parentelement.getattribute ("style"). backgroundcolor= "";
name=row+ "Button1";
Document.all[name].getattribute ("style"). display= "inline";
}
}

</SCRIPT>
<asp:datagrid id= "GridItem" runat= "server" cellpadding= "0" borderstyle= "Solid" autogeneratecolumns= "False"
Width= "100%" allowpaging= "True" >
<selecteditemstyle backcolor= "Lightyellow" ></SelectedItemStyle>
<edititemstyle cssclass= "Tdbg-dark" backcolor= "Ivory" ></EditItemStyle>
<itemstyle horizontalalign= "Center" height= "23px" cssclass= "tdbg" ></ItemStyle>
<Columns>
<asp:boundcolumn datafield= "id" readonly= "True" headertext= "person number" >
</asp:BoundColumn>
<asp:boundcolumn readonly= "True" headertext= "name" >
</asp:BoundColumn>
<asp:templatecolumn headertext= "Management rights" >
<ItemTemplate>
<input id= "Checkbox1" style= "Display:none" type= "checkbox" runat= "Server" >
<input id= "Text1" type= "text" runat= "server" style= "Display:none" >
</ItemTemplate>
</asp:TemplateColumn>
<asp:templatecolumn headertext= "Query Right" >
<ItemTemplate>
<input id= "Checkbox2" style= "Display:none" type= "checkbox" runat= "Server" name= "Checkbox2" >
<input id= "Text2" type= "text" runat= "server" style= "Display:none" name= "Text2" >
</ItemTemplate>
</asp:TemplateColumn>
<asp:templatecolumn headertext= "input Right" >
<ItemTemplate>
<input id= "Checkbox3" style= "Display:none" type= "checkbox" runat= "Server" name= "Checkbox3" >
<input id= "Text3" type= "text" runat= "server" style= "Display:none" name= "Text3" >
</ItemTemplate>
</asp:TemplateColumn>
<asp:templatecolumn headertext= "modification Right" >
<ItemTemplate>
<input id= "Checkbox4" style= "Display:none" type= "checkbox" runat= "Server" name= "Checkbox4" >
<input id= "TEXT4" type= "text" runat= "server" style= "Display:none" name= "TEXT4" >
</ItemTemplate>
</asp:TemplateColumn>
<asp:templatecolumn headertext= "Delete Right" >
<ItemTemplate>
<input id= "Checkbox5" style= "Display:none" type= "checkbox" runat= "Server" name= "CHECKBOX5" >
<input id= "TEXT5" type= "text" runat= "server" style= "Display:none" name= "TEXT5" >
</ItemTemplate>
</asp:TemplateColumn>
<asp:templatecolumn headertext= "Export Right" >
<ItemTemplate>
<input id= "Checkbox6" style= "Display:none" type= "checkbox" runat= "Server" name= "Checkbox6" >
<input id= "Text6" type= "text" runat= "server" style= "Display:none" name= "Text6" >
</ItemTemplate>
</asp:TemplateColumn>
<asp:templatecolumn headertext= "Import Right" >
<ItemTemplate>
<input id= "Checkbox7" style= "Display:none" type= "checkbox" runat= "Server" name= "Checkbox7" >
<input id= "Text7" type= "text" runat= "server" style= "Display:none" name= "Text7" >
</ItemTemplate>
</asp:TemplateColumn>
<asp:buttoncolumn text= "Save" headertext= "Operation" commandname= "Cmdsave" >
<itemstyle font-size= "10pt" ></ItemStyle>
</asp:ButtonColumn>
<asp:TemplateColumn>
<ItemTemplate>
<input id= "Button1" style= "Cursor:hand; width:35px; Color:blue; Border-top-style:none; Border-right-style:none; Border-left-style:none; Background-color:transparent; Text-decoration:underline; Border-bottom-style:none "
onclick= "Editcell (this,1);" type= "button" value= "edit" runat= "Server" ><input id= "Button2" style= "Cursor:hand"; Display:none; Color:blue; Border-top-style:none; Border-right-style:none; Border-left-style:none; Background-color:transparent; Text-decoration:underline; Border-bottom-style:none "
onclick= "Editcell (this,2);" type= "button" value= "Cancel" runat= "Server" >
</ItemTemplate>
</asp:TemplateColumn>
</Columns>
<pagerstyle nextpagetext= "Next" prevpagetext= "prev" ></PagerStyle>
</asp:datagrid>



Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.