Answered by:
Populate a gridview in a modal popup?

Question
-
User-1767698477 posted
Can this be done? I have a popup which edits gridview rows. I want to have a gridview on the popup which contains data related to the data being edited. At the moment, the gridview is not appearing. I have tried to the the databind both before and after showing the modal pop and neither method is working.
Protected Sub editbtnre_Click(ByVal sender As Object, ByVal e As ImageClickEventArgs) btn2Update.Text = "Update" lblresult2.Visible = False Dim row As GridViewRow = TryCast((CType(sender, Control)).Parent.NamingContainer, GridViewRow) Dim key As String = GridView2.DataKeys(row.RowIndex).Value.ToString() Dim tblrealestateadapter As New DataSet1TableAdapters.RealestateTableAdapter Dim tblrealestate As DataSet1.RealestateDataTable tblrealestate = tblrealestateadapter.GetData(key) For Each tblrerow As DataSet1.RealestateRow In tblrealestate Dim btndetails As ImageButton = TryCast(sender, ImageButton) Dim gvrow As GridViewRow = DirectCast(btndetails.NamingContainer, GridViewRow) 'lblID.Text = GridView1.DataKeys(gvrow.RowIndex).Value.ToString() Dim type As String = "" cbsubject.Checked = tblrerow.propertysubject txtstreet.Text = tblrerow.propertystreet txtvalue.Text = tblrerow.propertyvalue Ddpropertystatus.SelectedValue = tblrerow.propertydispo DDoccupancynew.SelectedValue = tblrerow.propertyoccnew If tblrerow.propertytiho = 0 Then txtinstaxassoc.Text = "" Else txtinstaxassoc.Text = tblrerow.propertytiho End If cbomitted.Checked = tblrerow.propertytihoomitted ddunitdesignator.SelectedValue = tblrerow.propertyunitdesignator txtunitnum.Text = tblrerow.propertyunitnum DDoccupancycur.SelectedValue = tblrerow.propertyoccnow cbcondo.Checked = tblrerow.propertycondo cbcoop.Checked = tblrerow.propertycoop If tblrerow.propertyrentalinc = 0 Then txtrentalinc.Text = "" Else txtrentalinc.Text = tblrerow.propertyrentalinc End If txtcity.Text = tblrerow.propertycity txtstate.Text = tblrerow.propertystate txtzip.Text = tblrerow.propertyzip txtunits.Text = tblrerow.propertytotunits ddcountry.SelectedValue = tblrerow.propertycountry If tblrerow.propertyoccrate = 0 Then txtoccrate.Text = "" Else txtoccrate.Text = tblrerow.propertyoccrate End If If tblrerow.propertynetinc = 0 Then txtnetrent.Text = "" Else txtnetrent.Text = tblrerow.propertynetinc End If btn2Insert.Visible = False btn2Update.Visible = True Next 'initialize the mortgage gridview HiddenField2.Value = key Me.ModalPopupExtender2.Show() Dim tblliabilitiesadapter As New DataSet1TableAdapters.LiabilitiesTableAdapter Dim tblliabilities As DataSet1.LiabilitiesDataTable tblliabilities = tblliabilitiesadapter.GetMortgages(CInt(Session("ApplicantID"))) GridView3.DataSource = tblliabilities GridView3.DataBind() End Sub
<tr> <td colspan="4" align="center"> <asp:GridView ID="GridView3" runat="server" ></asp:GridView> </td> </tr> <tr> <td colspan="4" align="center"> <br /> <asp:HiddenField ID="HiddenField2" runat="server" /> <asp:Button ID="btn2Update" CommandName="Update" runat="server" Text="Update" OnClick="btn2Update_Click" /> <asp:Button ID="btn2Insert" CommandName="Insert" runat="server" Text="Add" OnClick="btn2Insert_Click" /> <asp:Button ID="btn2Cancel" runat="server" Text="Cancel" /> </td> <td></td> <td></td> <td></td> </tr> </table> </asp:Panel>
Sunday, May 23, 2021 3:36 AM
Answers
-
User-1767698477 posted
I was able to get this resolved and working.
'initialize the mortgage gridview
Dim tblliabilitiesadapter As New DataSet1TableAdapters.LiabilitiesTableAdapter
Dim tblliabilities As DataSet1.LiabilitiesDataTable
tblliabilities = tblliabilitiesadapter.GetMortgages(CInt(Session("ApplicantID")))
GridView4.DataSource = tblliabilities
GridView4.DataBind()<tr> <td colspan="4" align="center"> <div style="overflow-x: scroll; overflow-y: scroll; height: 100px; width: 840px"> <br /> <asp:GridView ID="GridView4" runat="server" AutoGenerateColumns="false" RowStyle-Wrap="False" HeaderStyle-Wrap="False" HeaderStyle-Font-Size="X-Small" OnRowDataBound="Gridview4_rowdatabound" CellPadding="3" HorizontalAlign="Center" > <RowStyle HorizontalAlign="Center" /> <Columns> <asp:BoundField DataField="Type" HeaderText="Type" SortExpression="Type" ItemStyle-Width="100px" /> <asp:BoundField DataField="Mortgagetype" HeaderText="Mortgagetype" SortExpression="Mortgagetype" ItemStyle-Width="100px" /> <asp:BoundField DataField="Company" HeaderText="Company" SortExpression="Company" ItemStyle-Width="100px" /> <asp:BoundField DataField="Acctnum" HeaderText="Acctnum" SortExpression="Acctnum" ItemStyle-Width="100px" /> <asp:BoundField DataField="Company" HeaderText="Company" SortExpression="Company" ItemStyle-Width="100px" /> <asp:BoundField DataField="Balance" HeaderText="Balance" SortExpression="Balance" ItemStyle-Width="100px" /> <asp:BoundField DataField="PaidPTC" HeaderText="Paid PTC" SortExpression="PaidPTC" ItemStyle-Width="100px" /> <asp:BoundField DataField="Paidatclosing" HeaderText="Paid at Closing" SortExpression="Paidatclosing" ItemStyle-Width="100px" /> <asp:BoundField DataField="Omit" HeaderText="Omit" SortExpression="Omit" ItemStyle-Width="100px" /> <asp:BoundField DataField="Mopmt" HeaderText="Payment" SortExpression="Mopmt" ItemStyle-Width="100px" /> <asp:BoundField DataField="Molefttopay" HeaderText="Months left" SortExpression="Molefttopay" ItemStyle-Width="100px" /> <asp:BoundField DataField="CreditLimit" HeaderText="Credit Limit" SortExpression="CreditLimit" ItemStyle-Width="100px" /> <asp:BoundField DataField="Resub" HeaderText="Resubordinated" SortExpression="Resub" ItemStyle-Width="100px" /> </Columns> </asp:GridView> </div> </td> </tr>
- Marked as answer by An0nym0u5User Tuesday, September 21, 2021 12:00 AM
Sunday, May 23, 2021 5:29 PM