Mehram says:
ScriptManager.RegisterClientScriptBlock(
Me
,
Me
.
GetType
(),
"none"
,
"<script>$('#mymodal').modal('show');</script>"
,
False
)
Hi mehram,
You are making mistake in above quoted Code.
For more details please Refer below sample.
HTML
<div class="modal fade" id="myModal" role="dialog">
<div class="modal-dialog">
<!-- Modal content-->
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">
×</button>
<h4 class="modal-title">Student Fee Details</h4>
</div>
<div class="modal-body">
<div class="">
<div class="form-group">
<asp:Label ID="lblstudent" runat="server" Text="Aadmission No: "></asp:Label>
<asp:Label ID="lblstudentid" runat="server" Text=""></asp:Label>
</div>
<div class="form-group">
<asp:Label ID="Label1" runat="server" Text="Month"></asp:Label>
<asp:Label ID="lblmonth" runat="server" Text=""></asp:Label>
</div>
<div class="form-group">
<asp:Label ID="lblAmount" runat="server" Text="Amount"></asp:Label>
<asp:TextBox ID="txtAmount" runat="server" TabIndex="3" MaxLength="75" CssClass="form-control"
placeholder="Enter Amount"></asp:TextBox>
</div>
</div>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-info" data-dismiss="modal">
Close</button>
<asp:Button ID="btnSave" runat="server" Text="Save" OnClick="btnSave_Click" CssClass="btn btn-info" />
</div>
</div>
</div>
</div>
<asp:GridView ID="gvEducationlDet" runat="server" CssClass="table table-striped table-hover"
DataKeyNames="student_Id" AutoGenerateColumns="false" GridLines="None">
<Columns>
<asp:TemplateField HeaderText="Admission No">
<ItemTemplate>
<asp:Label ID="lblstudent_Id" runat="server" Text='<%# Eval("student_Id") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Month">
<ItemTemplate>
<asp:Label ID="lblMonth_Name" runat="server" Text='<%# Eval("Month_Name") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Amount">
<ItemTemplate>
<asp:Label ID="lblAmount" runat="server" Text='<%# Eval("Amount") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="IsPaid">
<ItemTemplate>
<asp:Label ID="lblIsPaid" runat="server" Text='<%# Eval("IsPaid") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="date">
<ItemTemplate>
<asp:Label ID="lbldate" runat="server" Text='<%# Eval("date") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Pay">
<ItemTemplate>
<asp:LinkButton ID="lnkBtnEdit" runat="server" Text="Edit" CssClass="btn btn-info"
OnClick="Display"></asp:LinkButton>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
Namespace
C#
using System.Data;
VB.Net
Imports System.Data
Code
C#
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
DataTable dt = new DataTable();
dt.Columns.AddRange(new DataColumn[] {
new DataColumn("student_Id")
,new DataColumn("Month_Name")
,new DataColumn("Amount")
,new DataColumn("IsPaid")
,new DataColumn("date")
});
dt.Rows.Add(1, "Jan", 5200, "Yes", DateTime.Now.AddDays(-263));
dt.Rows.Add(2, "Feb", 6500, "No", DateTime.Now.AddDays(-50));
dt.Rows.Add(3, "Mar", 7500, "", "");
dt.Rows.Add(4, "Apr", 6333, "No", DateTime.Now.AddDays(-63));
dt.Rows.Add(5, "Jun", 15000, "Yes", DateTime.Now.AddDays(-93));
gvEducationlDet.DataSource = dt;
gvEducationlDet.DataBind();
}
}
protected void Display(object sender, EventArgs e)
{
int rowIndex = Convert.ToInt32(((sender as LinkButton).NamingContainer as GridViewRow).RowIndex);
GridViewRow row = gvEducationlDet.Rows[rowIndex];
lblstudentid.Text = (row.FindControl("lblstudent_Id") as Label).Text;
lblmonth.Text = (row.FindControl("lblMonth_Name") as Label).Text; ;
txtAmount.Text = (row.FindControl("lblAmount") as Label).Text;
ScriptManager.RegisterStartupScript(this, this.GetType(), "modal", "<script>window.onload=function(){$('#myModal').modal('show');}</script>", false);
}
protected void btnSave_Click(object sender, EventArgs e)
{
}
VB.Net
Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load
If Not IsPostBack Then
Dim dt As DataTable = New DataTable()
dt.Columns.AddRange(New DataColumn() {New DataColumn("student_Id"), New DataColumn("Month_Name"), New DataColumn("Amount"), New DataColumn("IsPaid"), New DataColumn("date")})
dt.Rows.Add(1, "Jan", 5200, "Yes", DateTime.Now.AddDays(-263))
dt.Rows.Add(2, "Feb", 6500, "No", DateTime.Now.AddDays(-50))
dt.Rows.Add(3, "Mar", 7500, "", "")
dt.Rows.Add(4, "Apr", 6333, "No", DateTime.Now.AddDays(-63))
dt.Rows.Add(5, "Jun", 15000, "Yes", DateTime.Now.AddDays(-93))
gvEducationlDet.DataSource = dt
gvEducationlDet.DataBind()
End If
End Sub
Protected Sub Display(ByVal sender As Object, ByVal e As EventArgs)
Dim rowIndex As Integer = Convert.ToInt32((TryCast((TryCast(sender, LinkButton)).NamingContainer, GridViewRow)).RowIndex)
Dim row As GridViewRow = gvEducationlDet.Rows(rowIndex)
lblstudentid.Text = (TryCast(row.FindControl("lblstudent_Id"), Label)).Text
lblmonth.Text = (TryCast(row.FindControl("lblMonth_Name"), Label)).Text
txtAmount.Text = (TryCast(row.FindControl("lblAmount"), Label)).Text
ScriptManager.RegisterStartupScript(Me, Me.GetType(), "modal", "<script>window.onload=function(){$('#myModal').modal('show');}</script>", False)
End Sub
Protected Sub btnSave_Click(ByVal sender As Object, ByVal e As EventArgs)
End Sub
Screenshot