Requirements: Read data from the HR Database info table, displayed in the Web site as
Use the DW to draw a table and then copy the code to the new Web site home code
1<div>2 3<table bgcolor="Black"Border="0"cellpadding="5"cellspacing="1"Width="100%">4<tr>5<TD align="Center"Bgcolor="#99CC66"Width="10%"><strong> Code </strong></td>6<TD align="Center"Bgcolor="#99CC66"Width="20%"><strong> name </strong></td>7<TD align="Center"Bgcolor="#99CC66"Width="10%"><strong> Sex </strong></td>8<TD align="Center"Bgcolor="#99CC66"Width="20%"><strong> ethnic </strong></td>9<TD align="Center"Bgcolor="#99CC66"Width="20%"><strong> Birthdays </strong></td>Ten<TD align="Center"Bgcolor="#99CC66"Width="20%"><strong> Operations </strong></td> One</tr> A<% -Mydbdatacontext context =NewMydbdatacontext (); - varquery =context. Info; the foreach(Info datainchquery) - { -%> -<tr> +<TD align="Center"Bgcolor="#CCFFFF"><%=data. Code%></td> -<TD align="Center"Bgcolor="#CCFFFF"><%=data. Name%></td> +<TD align="Center"Bgcolor="#CCFFFF"><%= (data. sex.value==true?"male":"female")%></td> A<TD align="Center"Bgcolor="#CCFFFF"><%=data. Nation1.name%></td> at<TD align="Center"Bgcolor="#CCFFFF"><%=data. Birthday.Value.ToString ("yyyy mm month DD Day")%></td> -<TD align="Center"Bgcolor="#CCFFFF"><a href="Delete.aspx?aaa=<%=data. Code%>"> Delete </a></td> -</tr> -<% - } -%> in</table> - to</div>
The code for the delete operation:
1<div>2<%3 //gets the primary key value passed over4 strings = request["AAA"]. ToString ();5 //Perform the delete6Mydbdatacontext context =NewMydbdatacontext ();7 varQ = context.Info.Where (p = = P.code = =s);8 if(Q.count () >0)9 {TenInfo data =Q.first (); One A context. Family.deleteallonsubmit (data. Family); - context. Work.deleteallonsubmit (data. work); - context.Info.DeleteOnSubmit (data); the - context. SubmitChanges (); - } - //jump back to Default.aspx +Response.Redirect ("Default.aspx"); - +%> A</div>
2014.12.01 b/s use vs Build Web site