Hello All,
I have a section where Period Start,Period End and submit button.
After submiting the bottom of the page displaying(List View) the period with Edit Button .If edit button click then Bottom Top Period Start and Period End
load with respective date and if you click on the Submit button then period will modifying .It is working fine.
But when i am implementing ajax then creating problem (List view edit button not populating respective Top Period Start and Period End data for modifying.
Listview is under UpdatePanel for implenting ajax. using ajax newly added period will displaying in a listbox perfectly.But When i want to edit that period it will not populating data.
The Page aspx page is as follows:
<table>
<tr>
<td colspan="3" align="center">
<asp:Label ID="lblMessage" runat="server"></asp:Label>
</td>
</tr>
<tr>
<td width="232"><div align="right">Period Start:</div></td>
<td width="13"></td>
<td width="174">
<asp:TextBox ID="txtPeriodStart" runat="server"></asp:TextBox>
<a href="javascript:show_calendar('<%=txtPeriodStart.ClientID%>');"><img height="20"
src="../Include/images/calendar2.gif" width="15" align="top" border="0"></a>
</td>
</tr>
<tr>
<td><div align="right">Period End:</div></td>
<td></td>
<td>
<asp:TextBox ID="txtPeriodEnd" runat="server"></asp:TextBox>
<a href="javascript:show_calendar('<%=txtPeriodEnd.ClientID%>');"><img height="20"
src="../Include/images/calendar2.gif" width="15" align="top" border="0"></a>
</td>
</tr>
<tr><td colspan="3" align="center"><asp:Button ID="btnCreate" runat="server"
Text=" Create " onclick="btnCreate_Click" /></td></tr>
<tr><td colspan="3">
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
</td></tr>
<tr>
<td colspan="3" align="center">
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<Triggers>
<asp:AsyncPostBackTrigger ControlID="btnCreate" EventName="Click" />
</Triggers>
<ContentTemplate>
<asp:ListView ID="lstPeriodMaster" runat="server" onitemcommand="lstPeriodMaster_ItemCommand"
onitemediting="lstPeriodMaster_ItemEditing" >
<LayoutTemplate>
<table style="border: solid 2px #336699;" cellspacing="0" cellpadding="3" rules="all">
<tr style="background-color: #336699; color: White;">
<th>Period ID</th>
<th>Period Start</th>
<th>Period End</th>
<th>Period Edit</th>
</tr>
<tbody>
<asp:PlaceHolder ID="itemPlaceHolder" runat="server" />
</tbody>
</table>
</LayoutTemplate>
<ItemTemplate>
<tr>
<th><%#DataBinder.Eval(Container.DataItem, "PeriodId")%></th>
<th><%#DataBinder.Eval(Container.DataItem, "PeriodStart")%></th>
<th><%#DataBinder.Eval(Container.DataItem, "PeriodEnd")%></th>
<th><asp:Button ID="btnEdit" CssClass="button_small" runat="server" CommandName="EDIT" Text="Edit" CommandArgument='<%#DataBinder.Eval(Container.DataItem, "PeriodId")%>' /></th>
</tr>
</ItemTemplate>
<AlternatingItemTemplate>
<tr style="background-color: #dadada;">
<th><%#DataBinder.Eval(Container.DataItem, "PeriodId")%></th>
<th><%#DataBinder.Eval(Container.DataItem, "PeriodStart")%></th>
<th><%#DataBinder.Eval(Container.DataItem, "PeriodEnd")%></th>
<th><asp:Button ID="btnEdit" CssClass="button_small" runat="server" CommandName="EDIT" Text="Edit" CommandArgument='<%#DataBinder.Eval(Container.DataItem, "PeriodId")%>' /></th>
</tr>
</AlternatingItemTemplate>
</asp:ListView>
</ContentTemplate>
</asp:UpdatePanel>
</td>
</tr>
</table>
The aspx.cs code is as follows:
protected void lstPeriodMaster_ItemCommand(object sender, ListViewCommandEventArgs e)
{
if (e.CommandName == "EDIT")
{
populatePeriodInfo(Convert.ToString(e.CommandArgument));
}
hdnData.Value = strData;
}
protected void lstPeriodMaster_ItemEditing(object sender, ListViewEditEventArgs e)
{
}
public void populatePeriodData()
{
bPeriodMaster bobj = new bPeriodMaster();
List<ePeriod> obj = new List<ePeriod>();
obj = bobj.PeriodInfo();
if (obj.Count > 0)
{
lstPeriodMaster.DataSource = obj;
lstPeriodMaster.DataBind();
}
}
public void populatePeriodInfo(string period_ID)
{
bPeriodMaster bobj = new bPeriodMaster();
List<ePeriod> obj = new List<ePeriod>();
obj = bobj.PeriodInfo(period_ID);
if (obj.Count > 0)
{
txtPeriodStart.Text = obj[0].PeriodStart;
txtPeriodEnd.Text = obj[0].PeriodEnd;
strData = obj[0].PeriodStart;
if (obj[0].PeriodStatus == "Y")
{
chkPeriodStatus.Checked = true;
}
hdnPeriodID.Value = obj[0].PeriodId;
}
}
Can any one highlighting this issue???