Asp. NET simplified editing interface solution and implementation code (2) _ Practical skills

Source: Internet
Author: User
Tags eval
The program is a need for continuous improvement, the morning is done, the afternoon to see when it will feel that it is not perfect.
For example: http://www.jb51.net/article/33563.htm now insus.net change it to the following:


This with the previous improvement section, perhaps you will notice that the animation demo, mainly gridveiw update and delete will be in every row. So Insus.net took it out and placed it outside the GridView. To update multiple records at once, Insus.net has already recorded a video download address earlier. Another is to delete, the first column in each row put a checkbox, so that users can select records to delete.
Copy Code code as follows:

<asp:TemplateField>
<itemstyle borderwidth= "1" bordercolor= "#c0c0c0" width= "1%"/>
<ItemTemplate>
<asp:checkbox id= "CheckBox1" runat= "Server" onclick= "Javascript:changerowbgcolor (This)"/>
</ItemTemplate>
</asp:TemplateField>

Before the deletion prompts the user to confirm, then deletes, but in here meets the question, is first determines whether has the choice record, then confirm the user confirms deletes
There is also a point to pay attention to the place, is to select the checkbox, the line can be highlight, the implementation can refer to: http://www.jb51.net/article/33558.htm
The following is a more complete code for reference only:
Copy Code code as follows:

<asp:table id= "Table1" runat= "Server" cssclass= "Table" cellpadding= "2" cellspacing= "0" >
<asp:tableheaderrow height= "backcolor=" "#efebde" borderwidth= "1" bordercolor= "#c0c0c0" >
<asp:tableheadercell backcolor= "#efebde" borderwidth= "1" bordercolor= "#c0c0c0" >
Chinese Name
</asp:TableHeaderCell>
<asp:tableheadercell backcolor= "#efebde" borderwidth= "1" bordercolor= "#c0c0c0" width= "50%" >
中文版 Name
</asp:TableHeaderCell>
</asp:TableHeaderRow>
<asp:tablerow height= ">"
<asp:tablecell borderwidth= "1" bordercolor= "#c0c0c0" >
<asp:textbox id= "Txt_cname" runat= "Server" cssclass= "TextBox"/>
</asp:TableCell>
<asp:tablecell borderwidth= "1" bordercolor= "#c0c0c0" >
<asp:textbox id= "Txt_ename" runat= "Server" cssclass= "TextBox"/>
</asp:TableCell>
</asp:TableRow>
</asp:Table>
<div style= "MARGIN-TOP:3PX; margin-bottom:3px; padding:3px; " >
<asp:button id= "Buttoninsert" text= "Insert" runat= "Server" onclick= "Buttoninsert_click"/>
<asp:button id= "Buttonupdate" text= "Update" runat= "Server" onclick= "Buttonupdate_click"/>
<asp:button id= "Buttondelete" text= "Delete" runat= "Server" onclick= "Buttondelete_click"
Causesvalidation= "false"/>
</div>
<asp:gridview id= "Gvcuttertype" runat= "Server" datakeynames= "Cuttertypeid" autogeneratecolumns= "false"
cellpadding= "2" cellspacing= "0" width= "100%" borderwidth= "0" bordercolor= "#c0c0c0"
rowstyle-height= "showheader=" "false" >
<Columns>
<asp:TemplateField>
<itemstyle borderwidth= "1" bordercolor= "#c0c0c0" width= "1%"/>
<ItemTemplate>
<asp:checkbox id= "CheckBox1" runat= "Server" onclick= "Javascript:changerowbgcolor (This)"/>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField>
<itemstyle borderwidth= "1" bordercolor= "#c0c0c0"/>
<ItemTemplate>
<asp:textbox id= "Txtcname" runat= "server" text= ' <%# Eval ("CName")%> ' ></asp:TextBox>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField>
<itemstyle borderwidth= "1" bordercolor= "#c0c0c0" width= "50%"/>
<ItemTemplate>
<asp:textbox id= "Txtename" runat= "server" text= ' <%# Eval ("ename")%> ' ></asp:TextBox>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>

Xxx.aspx.cs:
Copy Code code as follows:

protected void Buttoninsert_click (object sender, EventArgs e)
{
// Do Insert something
//obj. Insert (...);
}
protected void Buttonupdate_click (object sender, EventArgs e)
{
//reference this url:http://www.c Nblogs.com/insus/articles/1400150.html
}
protected void Buttondelete_click (object sender, EventArgs e)
{
//String datakeynames = XXX;
//string[] arr = datakeynames.substring (1). Split (', ');
Try
{
foreach (string s in arr)
{
//obj. Delter (s);
}

catch (Exception ex)
{
//alert Exception message
}
}
Related Article

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.