24 protected int EventEditId
25 {
26 get { return Convert.ToInt32(this.Session["EventEditId"]); }
27 set { this.Session["EventEditId"] = value; }
28 }
59 protected void bEdit_Click(object sender, EventArgs e)
60 {
61 string Id = ((ImageButton)sender).CommandArgument;
62 this.EventEditId = Convert.ToInt32(Id);
63 this.lvEvents.DataBind();
64 }
30 protected string EventEditNewName
31 {
32 get { return this.Session["EventEditNewName"].ToString(); }
33 set { this.Session["EventEditNewName"] = value; }
34 }
66 protected void bSave_Click(object sender, EventArgs e)
67 {
68 ListViewDataItem lvi = ((ImageButton)sender).NamingContainer as ListViewDataItem;
69 EventEditNewName = ((TextBox)lvi.FindControl("tbEventName")).Text;
70 this.odsEvents.Update();
71 this.EventEditId = -1;
72 }
79 protected void odsEvents_Updating(object sender, ObjectDataSourceMethodEventArgs e)
80 {
81 e.InputParameters["EventName"] = EventEditNewName;
82 e.InputParameters["EventId"] = this.EventEditId;
83 }
37 <asp:ListView ID="lvEvents" runat="server" DataSourceID="odsEvents" DataKeyNames="EventID"
38 ondatabound="lvEvents_DataBound" >
42 <LayoutTemplate>
43 <table cellpadding="0" cellspacing="0" class="main">
44 <tr>
45 <th width="95%">
46 <asp:LinkButton ID="lbSortEventName" Text="Event Name"
47 CommandName="Sort" CommandArgument="EventName runat="server" />
48 </th>
49 <th class="center end">Edit</th>
50 </tr>
51 <asp:PlaceHolder ID="itemPlaceholder" runat="server"></asp:PlaceHolder>
52 </table>
53 </LayoutTemplate>
54 <ItemTemplate>
55 <tr class='<%# Container.DataItemIndex % 2 == 0?"even":"odd" %> fonts' >
56 <td>
57 <asp:Label ID="Label1" runat="server"
58 Visible='<%# (this.EventEditId != Convert.ToInt32(Eval("EventID"))) %>'
59 Text='<%# Eval("EventName")%>' ></asp:Label>
60 <asp:TextBox ID="tbEventName" runat="server"
61 Visible='<%# (this.EventEditId == Convert.ToInt32(Eval("EventID"))) %>'
62 Text='<%# Eval("EventName")%>' ></asp:TextBox>
64 </td>
65 <td class="center">
66
67 <asp:ImageButton ImageUrl="../Content/Images/icon-edit.png"
68 ID="ibEditEvent" AlternateText="Edit Event" runat="server"
69 OnClick="bEdit_Click" CommandArgument='<%#Eval("EventID") %>'
70 Visible="<%# (this.EventEditId == -1) %>"
71 CommandName="Select" />
72 <asp:ImageButton ImageUrl="../Content/Images/icon-approved.png"
73 ID="ibSaveEvent" AlternateText="Save Event" runat="server"
74 OnClick="bSave_Click" CommandArgument='<%#Eval("EventID") %>'
75 Visible='<%# (this.EventEditId == Convert.ToInt32(Eval("EventID"))) %>'
76 CommandName="Update" />
77 <asp:ImageButton ImageUrl="../Content/Images/icon-error-small.png"
78 ID="ibCancelEditEvent" AlternateText="Cancel Edit" runat="server"
79 OnClick="bCancel_Click" CommandArgument='<%#Eval("EventID") %>'
80 Visible='<%# (this.EventEditId == Convert.ToInt32(Eval("EventID"))) %>'
81 />
83 </td>
84 </tr>
85 </ItemTemplate>
86 </asp:ListView>
No comments:
Post a Comment