Tuesday, August 28, 2012

DataList Control ASPX

<asp:DataList ID="dlistTest" runat="server" Style="width: 30%" AlternatingItemStyle-BackColor="AliceBlue" BorderWidth="2px" OnEditCommand="dlistTest_EditCommand"
onupdatecommand="dlistTest_UpdateCommand" oncancelcommand="dlistTest_CancelCommand"
 ondeletecommand="dlistTest_DeleteCommand">
 <HeaderTemplate>
 <table style="width: 100%">
<tr><td style="width: 40%">Name </td><td style="width: 40%">Age</td>
<td style="width: 20%"></td></tr></table>
 </HeaderTemplate>
<ItemTemplate>
 <table style="width: 100%"> <tr> <td style="width: 30%">
 <asp:Label runat="server" ID="lblName" Text='<%#Eval("Name")%>'></asp:Label>
 </td><td style="width: 30%">
 <asp:Label runat="server" ID="lblAge" Text='<%#Eval("Age")%>'></asp:Label></td>
<td style="width: 40%">
<asp:Label runat="server" ID="lblIDDelete" Text='<%#Eval("ID")%>' ></asp:Label>
<asp:LinkButton runat="server" ID="lbtnEdit" CommandName="Edit">Edit</asp:LinkButton>&nbsp;&nbsp;
<asp:LinkButton runat="server" ID="lbtnDelete" CommandName="Delete">Delete</asp:LinkButton>
 </td></tr></table>
</ItemTemplate>
<EditItemTemplate>
 <table style="width: 100%">
 <tr><td style="width: 10%">Name</td>
<td style="width: 20%">
<asp:TextBox runat="server" ID="txtName" Text='<%#Bind("Name")%>' Width="60px"></asp:TextBox>
</td>
<td style="width: 10%">Age </td>
<td style="width: 20%">
<asp:TextBox runat="server" ID="txtAge" Text='<%#Bind("Age")%>' Width="60px"></asp:TextBox>
</td>
<td style="width: 40%">
<asp:Label runat="server" ID="lblID" Text='<%#Eval("ID")%>' ></asp:Label></td>
</tr><tr><td></td><td></td>
<td colspan="3">
<asp:Button runat="server" ID="btnUpdate" CommandName="Update" Text="Update" />
 <asp:Button runat="server" ID="btnCancel" CommandName="Cancel" Text="Cancel" />
</td></tr></table>
</EditItemTemplate>
</asp:DataList>

No comments:

Post a Comment