I used ModalPopupExtender today only ,so i have not much idea how it works
i am stuck in problem here
i have Gridview showing all students data,now when i click on Linkbutton of particular student in Gridview than that student data should shown in Detailsview on popup
i am getting a perticular student data in Detailsview but its not showing in popup,should i have to add anything else here?
here is my code for modelpopupextender
for aspx -
<pre><asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False"
DataKeyNames="Stu_id" onselectedindexchanged="GridView1_SelectedIndexChanged">
<Columns>
<asp:TemplateField HeaderText="ID">
<EditItemTemplate>
<asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("Stu_id") %>'></asp:TextBox>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="Label1" runat="server" Text='<%# Bind("Stu_id") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="Fullname" HeaderText="name" />
<asp:BoundField DataField="Username" HeaderText="Username" />
<asp:BoundField DataField="Email" HeaderText="Email" />
<asp:TemplateField ShowHeader="False">
<ItemTemplate>
<asp:LinkButton ID="btnviewdetails" runat="server" CausesValidation="false"
CommandName="Select" Text="select" CommandArgument='<%# Eval("Stu_id") %>'
onclick="LinkButton1_Click"></asp:LinkButton>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
</ContentTemplate>
</asp:UpdatePanel>
<asp:Button ID="btnshowpopup" runat="server"/>
<asp:ModalPopupExtender ID="mdlpopup" runat="server" TargetControlID="btnshowpopup" PopupControlID="pnlpopup" CancelControlID="btncancel" BackgroundCssClass="pop">
</asp:ModalPopupExtender>
<asp:Panel ID="pnlpopup" runat="server" Width="500px" style="display:none">
<asp:UpdatePanel ID="UpdatePanel2" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<asp:DetailsView ID="DetailsView1" runat="server" AutoGenerateRows="False" DataKeyNames="Stu_id" Height="50px" Width="125px">
<Fields>
<asp:BoundField DataField="Stu_id" HeaderText="ID" />
<asp:BoundField DataField="Fullname" HeaderText="Fullname" />
<asp:BoundField DataField="Username" HeaderText="Username" />
<asp:BoundField DataField="Email" HeaderText="Email" />
</Fields>
</asp:DetailsView>
<div id="div1" style="display:none">
<asp:Button ID="btncancel" runat="server" Text="cancel" />
</div>
</ContentTemplate>
</asp:UpdatePanel>
</asp:Panel
cs code-
public partial class Admin_Default : System.Web.UI.Page
{
portalDal dal = new portalDal();
adminBal bal = new adminBal();
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
GridView1.DataSource = bal.student_bind();
GridView1.DataBind();
}
}
protected void LinkButton1_Click(object sender, EventArgs e)
{
}
protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
{
this.DetailsView1.Visible = true;
LinkButton l1 = (LinkButton)sender;
dal.stu_id = Convert.ToInt16(l1.CommandArgument);
DetailsView1.DataSource = bal.select_student(dal);
DetailsView1.DataBind();
this.UpdatePanel2.Update();
this.mdlpopup.Show();
}
bal file-
public DataTable student_bind()
{
con.Open();
cmd = new SqlCommand("select * from Stu_registration", con);
DataTable dt = new DataTable();
SqlDataAdapter da = new SqlDataAdapter(cmd);
da.Fill(dt);
con.Close();
return dt;
}
public DataTable aselect_student(portalDal dal)
{
con.Open();
cmd = new SqlCommand("select_student", con);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.AddWithValue("@Stu_id", dal.stu_id);
DataTable dt = new DataTable();
SqlDataAdapter da = new SqlDataAdapter(cmd);
da.Fill(dt);
con.Close();
return dt;
}