I am using a repeater control to display records,I m using javascript window.open to edit a record
I am having a problem in it that when i click on Update button first time it doesnot open window one should click second time on the button
Why is this problem arising?
Second i want to know how can i rebind repetear after updating the record
Third how can i close the opened javascript window just after updating record
Repeater Item Command ===>
<pre lang="cs">protected void rptuser_ItemCommand(object source, RepeaterCommandEventArgs e)
{
try
{
Usercls u = new Usercls();
if (e.CommandName == "upd")
{
int uid = Convert.ToInt32(e.CommandArgument);
Session["uid"] = u.GetUserbyID(uid)[0].UserId.ToString();
Session["fname"] = u.GetUserbyID(uid)[0].FirstName;
Session["lname"] = u.GetUserbyID(uid)[0].LastName;
Session["uname"] = u.GetUserbyID(uid)[0].Username;
Session["des"] = u.GetUserbyID(uid)[0].Designation;
ImageButton upd = (ImageButton)e.Item.FindControl("updbtn");
upd.OnClientClick = "return PopUp()";
}
else if (e.CommandName == "del")
{
int uid = Convert.ToInt32(e.CommandArgument);
u.DeleteUser(uid);
rptuser.DataBind();
}
}
catch (Exception ex)
{
throw ex;
}
}
Repeater ===>
<pre lang="xml"><asp:Repeater ID="rptuser" runat="server" DataSourceID="ObjectDataSource1"
OnItemCommand="rptuser_ItemCommand">
<HeaderTemplate>
<table>
<tr>
<td class="GridHeader"></td>
<td class="GridHeader">UserID:</td>
<td class="GridHeader">FirstName:</td>
<td class="GridHeader">LastName:</td>
<td class="GridHeader">Designation:</td>
<td class="GridHeader">UserName:</td>
<td class="GridHeader"></td>
</tr>
</HeaderTemplate>
<ItemTemplate>
<tr>
<td class="GridItems"><asp:ImageButton runat="server" ID="delbtn" ImageUrl="~/images/delete.gif" CommandName="del" CommandArgument='<%# Eval("UserId") %>' OnClientClick="return confirm('Are you sure to delete this User')" ValidationGroup="ab" ToolTip="Delete User" /></td>
<td class="GridItems"><%# DataBinder.Eval(Container.DataItem,"UserId") %></td>
<td class="GridItems"><%# DataBinder.Eval(Container.DataItem,"FirstName") %></td>
<td class="GridItems"><%# DataBinder.Eval(Container.DataItem,"LastName") %></td>
<td class="GridItems"><%# DataBinder.Eval(Container.DataItem,"Designation") %></td>
<td class="GridItems"><%# DataBinder.Eval(Container.DataItem,"Username") %></td>
<td class="GridItems"><asp:ImageButton ID="updbtn" ValidationGroup="Av" runat="server" ImageUrl="~/images/update.jpg" CommandName="upd" CommandArgument='<%# DataBinder.Eval(Container.DataItem,"UserId") %>' /></td>
</tr>
</ItemTemplate>
<FooterTemplate>
</table>
</FooterTemplate>
</asp:Repeater>
If i use OnClientClick inside repeater,it gives exception as it doesn't find appropriate session object