Click here to Skip to main content
15,881,248 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
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 -

C#
<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-


C#
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-

C#
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;
    }
Posted
Updated 23-Jan-14 6:29am
v4
Comments
JoCodes 23-Jan-14 22:40pm    
whats showing in the popup now? Is it not opening. Or Popup opening but detailsview is empty?
vikasvanvi 24-Jan-14 1:02am    
popup is not showing when i click on linkbutton btnviewdetails, and popup is showing when i click on button btnshowpopup but inside that detailsview is not showing

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900