2
Reply

How to bind gridview data on model pop up extender?

selva kumar

selva kumar

Sep 12 2013 8:59 AM
1.5k
Hi friends ..i want to bind the gridview data on popup extender..when i clicking button the gridview should bind the data with model popup extender..i tried but it doesn't bind the data..only model pop up window are displayed..can any one help me out..
Here is my code...

 <asp:ScriptManager ID="scriptmgr1" runat="server"></asp:ScriptManager>
  <ajaxToolkit:ModalPopupExtender ID="modelpopup1" BackgroundCssClass="modalBackground" PopupControlID="panel1" TargetControlID="Button1" Drag="true" runat="server">
  </ajaxToolkit:ModalPopupExtender>
  <asp:Panel ID="panel1" runat="server" CssClass="modalPopup"> 
  <table style="width: 614px">
  <tr>
  <td style="width: 100px;height:auto">
  </td>
  <td style="width: 100px;height:auto">
  </td>
  <td style="width: 100px;height:auto">
  </td>
  <td style="width: 100px;height:auto">
  </td>
  <td style="width: 100px;height:auto">
  </td>
  <td style="width: 100px;height:auto">
  </td>
  <td style="width: 100px;height:auto">
  </td>
  <td style="width: 100px;height:auto">
  </td>
  <td style="width: 100px;height:auto">
  </td>
  <td style="width: 100px;height:auto">
  </td>
  </tr>
  <tr>
  <td style="width: 100px;height:auto">
  </td>
  <td colspan="8" rowspan="6">
  <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False"
  CellPadding="4" ForeColor="#333333" Visible="true" GridLines="None" Width="617px">
  <RowStyle BackColor="#E3EAEB" />
  <FooterStyle BackColor="#1C5E55" Font-Bold="True" ForeColor="White" />
  <PagerStyle BackColor="#666666" ForeColor="White" HorizontalAlign="Center" />
  <SelectedRowStyle BackColor="#C5BBAF" Font-Bold="True" ForeColor="#333333" />
  <HeaderStyle BackColor="#1C5E55" Font-Bold="True" ForeColor="White" />
  <EditRowStyle BackColor="#7C6F57" />
  <AlternatingRowStyle BackColor="White" />
  <Columns>
  <asp:TemplateField>
  <ItemTemplate>
  <asp:Label ID="lblid" runat="server" Text='<%#Eval("T_ID")%>' Visible="false">
  </asp:Label>
  </ItemTemplate>
  </asp:TemplateField>
  <asp:TemplateField HeaderText="Name">
  <ItemTemplate>
  <asp:Label ID="lblname" runat="server" Text='<%#Eval("Name")%>'>
  </asp:Label>
  </ItemTemplate>
  </asp:TemplateField>
 
  <asp:TemplateField HeaderText="Class">
  <ItemTemplate>
  <asp:Label ID="lblclass" runat="server" Text='<%#Eval("Class")%>'>
  </asp:Label>
  </ItemTemplate>
 
  </asp:TemplateField>
  <asp:TemplateField HeaderText="Section">
  <ItemTemplate>
  <asp:Label ID="lblsection" runat="server" Text='<%#Eval("Section")%>'>
  </asp:Label>
  </ItemTemplate>
 
  </asp:TemplateField>
  <asp:TemplateField HeaderText="Date">
  <ItemTemplate>
  <asp:Label ID="lbldate" runat="server" Text='<%#System.DateTime.Now.ToString("dd/MM/yyyy")%>'>
  </asp:Label>
  </ItemTemplate>
  </asp:TemplateField>
  <asp:TemplateField HeaderText="Present">
  <ItemTemplate>
  <asp:RadioButtonList ID="rdio1" runat="server">
  <asp:ListItem Value="Present">Present</asp:ListItem>
  <asp:ListItem Value="Absent">Absent</asp:ListItem>
  </asp:RadioButtonList>
  <%--<asp:CheckBox ID="chkpresent" Text="Present" runat="server">
  </asp:CheckBox> --%>
  </ItemTemplate>
  </asp:TemplateField>
  <%-- <asp:TemplateField HeaderText="Absent">
  <ItemTemplate>
  <asp:CheckBox ID="chkabsent" Text="Absent" runat="server">
  </asp:CheckBox>
  </ItemTemplate>
  </asp:TemplateField>--%>
  </Columns>
  </asp:GridView>
  </td>
  <td style="width: 100px;height:auto">
  </td>
  </tr>
  <tr>
  <td style="width: 100px;height:auto">
  </td>
  <td style="width: 100px;height:auto">
  </td>
  </tr>
  <tr>
  <td style="width: 100px;height:auto">
  </td>
  <td style="width: 100px;height:auto">
  </td>
  </tr>
  <tr>
  <td style="width: 100px;height:auto">
  </td>
  <td style="width: 100px;height:auto">
  </td>
  </tr>
  <tr>
  <td style="width: 100px;height:auto">
  </td>
  <td style="width: 100px;height:auto">
  </td>
  </tr>
  <tr>
  <td style="width: 100px;height:auto">
  </td>
  <td style="width: 100px;height:auto">
  </td>
  </tr>
  <tr>
  <td style="width: 100px;height:auto">
  </td>
  <td style="width: 100px;height:auto">
  </td>
  <td style="width: 100px;height:auto">
  </td>
  <td style="width: 100px;height:auto">
  </td>
  <td style="width: 100px;height:auto">
  </td>
  <td style="width: 100px;height:auto">
  </td>
  <td style="width: 100px;height:auto">
  </td>
  <td style="width: 100px;height:auto">
  </td>
  <td style="width: 100px;height:auto">
  <asp:Button ID="Button1" runat="server" BackColor="PowderBlue" BorderColor="MidnightBlue"
  Font-Bold="True" Font-Names="Verdana" Text="Submit" Width="91px" OnClick="Button1_Click" /></td>
  <td style="width: 100px;height:auto">
  </td>
  </tr>
  <tr>
  <td style="width: 100px;height:auto">
  </td>
  <td style="width: 100px;height:auto">
  </td>
  <td style="width: 100px;height:auto">
  </td>
  <td style="width: 100px;height:auto">
  </td>
  <td style="width: 100px;height:auto">
  </td>
  <td style="width: 100px;height:auto">
  </td>
  <td style="width: 100px;height:auto">
  </td>
  <td style="width: 100px;height:auto">
  </td>
  <td style="width: 100px;height:auto">
  </td>
  <td style="width: 100px;height:auto">
  </td>
  </tr>
  <tr>
  <td style="width: 100px;height:22px">
  </td>
  <td style="width: 100px;height:22px">
  </td>
  <td style="width: 100px;height:22px">
  </td>
  <td style="width: 100px;height:22px">
  </td>
  <td style="width: 100px;height:22px">
  </td>
  <td style="width: 100px;height:22px">
  </td>
  <td style="width: 100px;height:22px">
  </td>
  <td style="width: 100px;height:22px">
  </td>
  <td style="width: 100px;height:22px">
  </td>
  <td style="width: 100px;height:22px">
  </td>
  </tr>
  </table>
  </asp:Panel>

cs code;

protected void Button1_Click(object sender, EventArgs e)
  {
  bind();
  }
public void bind()
  {
  try
  {
  Con.Open();

  Sdap = new SqlDataAdapter("select T_Id,[Name],Class,Section from student where Section='" + DropDownList1.SelectedItem.ToString() + "'", Con);
  DataSet Ds = new DataSet();
  Sdap.Fill(Ds);
  GridView1.DataSource = Ds;
  GridView1.DataBind();
  }
  catch (Exception Ex)
  {
  Response.Write(Ex.ToString());
  }
  finally
  {
  Con.Close();
  }
  }

Answers (2)