Why not bootstrap model opening in asp.net [Resolved]

Posted by Cpatil1000 under ASP.NET on 6/17/2016 | Points: 10 | Views : 572 | Status : [Member] | Replies : 1
Hi,

<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<div>
<asp:DataGrid ID="dgCurrent" runat="server" Width="940px" HorizontalAlign="Center"
OnRowCommand="dgCurrent_ItemCommand" AutoGenerateColumns="false" AllowPaging="false"
CssClass="table table-hover table-striped">
<Columns>
<asp:ButtonColumn CommandName="detail" Text="Detail"></asp:ButtonColumn>
<asp:BoundColumn DataField="ID" HeaderText="Code" />
<asp:BoundColumn DataField="FarmerName" HeaderText="Name" />
<asp:BoundColumn DataField="ContactNo" HeaderText="Continent" />
<asp:BoundColumn DataField="EmailID" HeaderText="Surface Area" />
</Columns>
</asp:DataGrid>
</div>
</ContentTemplate>
</asp:UpdatePanel>
<asp:UpdateProgress ID="UpdateProgress1" runat="server">
<ProgressTemplate>
<img src="" alt="Loading.. Please wait!" />
</ProgressTemplate>
</asp:UpdateProgress>
<div id="currentdetail" class="modal hide fade">
<div class="modal-header">
<asp:Button ID="bclose1" runat="server" class="close" Text="x" />
<h3 id="myModalLabel">
Detailed View</h3>
</div>
<div class="modal-body">
<asp:UpdatePanel ID="UpdatePanel2" runat="server">
<ContentTemplate>
<asp:DetailsView ID="DetailsView1" runat="server" CssClass="table table-bordered table-hover"
BackColor="White" ForeColor="Black" BorderStyle="Groove" AutoGenerateRows="False">
<Fields>
<asp:BoundField DataField="ID" HeaderText="Code" />
<asp:BoundField DataField="FarmerName" HeaderText="Name" />
<asp:BoundField DataField="ContactNo" HeaderText="Continent" />
<asp:BoundField DataField="EmailID" HeaderText="Surface Area" />
</Fields>
</asp:DetailsView>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="dgCurrent" EventName="ItemCommand" />
</Triggers>
</asp:UpdatePanel>
<div class="modal-footer">
<asp:Button ID="bClose" class="btn btn-info" Text="Close" runat="server" />
</div>
</div>
</div>


cs.Code :
protected void dgCurrent_ItemCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e)
{
DataTable sourceData;

try
{
{
GetFarmerStatusData();
sourceData = new DataTable();
sourceData = (DataTable)this.dgCurrent.DataSource;

int index = Convert.ToInt32(e.CommandArgument);






Responses

Posted by: A2H on: 6/17/2016 [Member] [MVP] Silver | Points: 50

Up
0
Down

Resolved
You need to add the code to open modalpop on ItemCommand event of DataGrid like below
//code to open popup
System.Text.StringBuilder strblr = new System.Text.StringBuilder();
strblr.Append(@"<script>");
strblr.Append(@"$('#currentdetail').modal('show');");
strblr.Append(@"</script>");
ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "script", strblr.ToString(), false);

Complete Code
 protected void dgCurrent_ItemCommand(object source, DataGridCommandEventArgs e)
{
DataTable sourceData;
try
{
{
GetFarmerStatusData();
sourceData = new DataTable();
sourceData = (DataTable)this.dgCurrent.DataSource;

int index = Convert.ToInt32(e.CommandArgument);

//code to open popup
System.Text.StringBuilder strblr = new System.Text.StringBuilder();
strblr.Append(@"<script>");
strblr.Append(@"$('#currentdetail').modal('show');");
strblr.Append(@"</script>");
ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "script", strblr.ToString(), false);
}
}
catch (Exception ex)
{
throw ex;
}
}


Thanks,
A2H
My Blog

Cpatil1000, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response