I have a DataGrid, to which I have added a template column for importing data to the data base.
I added the confirmation logic as discussed in this forum.
Now I have to click twice for the confirm box to appear.
I have a data grid with the template column. Below is the code:
Also the asp.net code which asks for confirmation. Below is the code:
I have to click on the link button twice, to get the confirm box populated.
Please help!
I added the confirmation logic as discussed in this forum.
Now I have to click twice for the confirm box to appear.
I have a data grid with the template column. Below is the code:
Code:
<asp:DataGrid ID="dgImportList" runat="server" Width="100%" BorderStyle="Solid" AutoGenerateColumns="False">
<AlternatingItemStyle CssClass="tabledata2"></AlternatingItemStyle>
<ItemStyle CssClass="tabledata1"></ItemStyle>
<HeaderStyle CssClass="tableHeader2"></HeaderStyle>
<Columns>
<asp:BoundColumn DataField="FileName" HeaderText="Name"></asp:BoundColumn>
<asp:BoundColumn DataField="Date" HeaderText="Date"></asp:BoundColumn>
<asp:ButtonColumn ButtonType="LinkButton" Text="Import" CommandName="Import"></asp:ButtonColumn>
<asp:ButtonColumn ButtonType="LinkButton" Text="Check" CommandName="FormatCheck">
</asp:ButtonColumn>
<asp:TemplateColumn>
<ItemTemplate>
<asp:LinkButton ID="lbImportTemplate"
runat="server"
CausesValidation="false"
CommandName="ImportTemplate"
Text="ImportTemplate"
OOnClick="ConfirmBtnClickHandler"></asp:LinkButton>
</ItemTemplate>
</asp:TemplateColumn>
</Columns> </asp:DataGrid>
Also the asp.net code which asks for confirmation. Below is the code:
Code:
private void dgImportList_ItemCommand(Object sender, DataGridCommandEventArgs e)
{
if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
{
LinkButton lb = e.Item.FindControl("lbImportTemplate") as LinkButton;
lb.OnClientClick = "if(!confirm('Are you sure to import this item?')){return false;}";
//Do something
}
Please help!
Comment