|
Greetings again,
Please forgive me for posting too much code. I am trying to post something that gives an idea of what I am struggling with.
Looking at the code, you can see there are 7 controls, GridView1, gvspouse, etc.
When the user queries the DB and there is say one row of data for say GridView1, the rest of the controls display one row of data. This is fine.
However, if the query returns two or more rows of data for one control, usually the rest of controls will show two or more empty rows of data.
This is not good.
We would like only the controls with two or more rows of data to return those rows and those controls that don't have any data to return just one row so user can fill that row if need be or leave it empty.
Is this possible?
Again, I apologize for too much code. My hope is that it helps convey the point I am trying to make when I say seven GridView controls.
Many thanks in advance
/HTML
<asp:UpdatePanel ID="PnlUsrDetails" runat="server">
<ContentTemplate>
<asp:MultiView ID="myMultiView" ActiveViewIndex="0" runat="server">
<asp:View ID="vwPersonalData" runat="server">
<!-- All user textboxes for input here -->
<span style="font-weight:bold;font-size:18px;color:#000000;">Name, title, and email address of employee filling this form</span><br /><br />
<div>
<div class="table-responsive">
<tablecccc>
<tr>
<td>
<div class="form-group">
<label id="lblEmpID">
<span style="font-weight: bold; font-size: 16px; color: #000000;">Enter your Employee Id to begin</span><span
style="color: #ff0000">*</span></label>
<asp:TextBox ID="txtEmpID" maxlength="10" placeholder="Badge ID..." Style="width: 150px;" class="form-control"
runat="server" AutoPostBack="true" OnTextChanged="txtEmpID_TextChanged"></asp:TextBox>
<br />
</div>
</td>
<td>
<div class="bd-callout bd-callout-danger" id="dprocessed" style="width:90%;" runat="server" visible="false">
<div id="checkusername" runat="server" visible="false" style="white-space:nowrap">
<asp:Label ID="lblStatus" runat="server"></asp:Label>
<asp:Image ID="imgstatus" runat="server" Width="17px" Height="17px" />
</div>
</div>
<div class="waitingdiv" id="loadingdiv" style="display:none;margin-left:5.3em">
<img src="images/ajax-loader.gif" alt="Loading" />Please wait...
</div>
</td>
</tr>
</tablecccc>
</div>
<div class="bd-callout bd-callout-danger" style="width:70%;">
<span style="color:#0093B2;font-weight:bold;font-size:1em;"> If you do not have an Employee ID, use the First Initial of first name + first initial of Last Name + date of birth in the format of MMDDYYYY. (For example, John Doe born January 1, 1900 will be, JD01011900)</span></div><br /><br />
<div class="table-responsive">
<table class="table">
<tr>
<td>
<div class="form-group">
<label for="lblEname"><span style="font-weight:bold;font-size:16px;color:#000000;">Employee Name</span><span style="color:#ff0000">*</span></label>
<asp:TextBox ID="txteName" placeholder="Employee name..." style="width:200px;" class="form-control" runat="server"></asp:TextBox>
<asp:RequiredFieldValidator id="RequiredFieldValidator2" Font-Bold="true"
SetFocusOnError="true" runat="server"
ErrorMessage="*" ControlToValidate="txteName" /><br />
</div>
</td>
<td>
<div class="form-group">
<label id="lblTitle"><span style="font-weight:bold;font-size:16px;color:#000000;">Your title</span><span style="color:#ff0000">*</span></label>
<asp:TextBox ID="txttitle" placeholder="Employee title..." style="width:200px;" class="form-control" runat="server"></asp:TextBox>
<asp:RequiredFieldValidator id="RequiredFieldValidator3" Font-Bold="true"
SetFocusOnError="true" runat="server"
ErrorMessage="*" ControlToValidate="txttitle" />
</div>
</td>
<td>
<div class="form-group">
<label id="lblEmail"><span style="font-weight:bold;font-size:16px;color:#000000;">Your email address</span><span style="color:#ff0000">*</span></label>
<asp:TextBox ID="txtemail" placeholder="Employee email..." style="width:200px;" class="form-control" runat="server"></asp:TextBox>
<asp:RequiredFieldValidator id="RequiredFieldValidator4" Font-Bold="true"
SetFocusOnError="true" runat="server"
ErrorMessage="*" ControlToValidate="txtemail" />
</div>
</td>
</tr>
</table>
</div>
<br /><br />
<div id="mainContainer" class="container">
<div class="shadowBox">
<div class="page-container">
<div class="container">
<div class="row">
<div class="col-lg-12 ">
<div class="table-responsive" data-pattern="priority-columns">
<span style="font-weight:bold;font-size:18px;color:#000000;">1. Name and address of Income Sources of $1,000.00 or greater of Employee (excluding income received from the organization):</span><br /><br />
<table class="table">
<tr>
<td>
<asp:gridview ID="Gridview1" RowStyle-Wrap="false" gridlines="None" CssClass="responsiveTable1" runat="server" ShowFooter="true" AutoGenerateColumns="false" onrowdatabound="Gridview1_RowDataBound" OnRowDeleting="Gridview1_RowDeleting">
<Columns>
<asp:BoundField DataField="RowNumber" Visible="false" HeaderText="Row Number" />
<asp:TemplateField HeaderText="Name">
<headerstyle horizontalalign="Left" />
<ItemTemplate>
<asp:TextBox ID="txtsourcename" Text='<%# Eval("sourcename") %>' placeholder="Name...(e.g, Jane Doe)" runat="server" style="width:375px;" AutoPostBack="true" class="form-control textClass" OnTextChanged="txtsourcename_TextChanged"></asp:TextBox><br />
<asp:CheckBox ID="grid1Details" ClientIDMode="Static" runat="server" Checked="false" AutoPostBack="true" OnCheckedChanged="Grid1CheckChanged" /><span style="color:#ff0000">*Check this box if N/A</span>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Address">
<ItemStyle HorizontalAlign="Left"></ItemStyle>
<ItemTemplate>
<asp:TextBox ID="txtsourceaddress" Text='<%# Eval("sourceaddress") %>' placeholder="Address..." runat="server" style="width:375px;" class="form-control textClass"></asp:TextBox><br /><br />
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="">
<ItemTemplate>
<asp:Button ID="ButtonAdd" runat="server" Text="Add another row if needed"
onclick="ButtonAdd_Click" CssClass="grvAddButton" /><br /><br /><br>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="">
<ItemTemplate>
<asp:Button ID="sourceDelete" runat="server" Text="Delete" CommandName="Delete"
CssClass="grvDelButton" OnClientClick="return confirm('Are you sure you want to remove this row?')" /> <br /><br /><br />
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:gridview>
</td>
</tr>
</table>
<span style="font-weight:bold;font-size:18px;color:#000000;">2. Name and address of Income Sources of $1,000.00 greater of Spouse, if any:</span>
<button type="button" class="btn btn-info" data-toggle="popover" title="Definition of Spouse" data-trigger="focus" data-content="For purposes of this ordinance, the term spouse includes a domestic partner as the Code of organization defines that term."></button><br />
<table class="table">
<tr>
<td>
<asp:gridview ID="grvspouse" RowStyle-Wrap="false" GridLines="None" CssClass="responsiveTable1" runat="server" ShowFooter="true" AutoGenerateColumns="false" onrowdatabound="grvspouse_RowDataBound" OnRowDeleting="grvspouse_RowDeleting">
<Columns>
<asp:BoundField DataField="SpouseNumber" Visible="false" HeaderText="Row Number" />
<asp:TemplateField HeaderText="Name">
<headerstyle horizontalalign="Left" />
<ItemTemplate>
<asp:TextBox ID="txtspousename" Text='<%# Eval("spousename") %>' placeholder="Name...(e.g, Jane Doe)" runat="server" style="width:375px;" class="form-control" AutoPostBack="true" OnTextChanged="txtspousename_TextChanged"></asp:TextBox><br />
<asp:CheckBox ID="spouseDetails" ClientIDMode="Static" runat="server" Checked="false" AutoPostBack="true" OnCheckedChanged="SpouseCheckChanged" /><span style="color:#ff0000">*Check this box if N/A</span>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Address">
<ItemStyle HorizontalAlign="Left"></ItemStyle>
<ItemTemplate>
<asp:TextBox ID="txtspouseaddress" Text='<%# Eval("spouseaddress") %>' placeholder="Address..." runat="server" style="width:375px;" class="form-control"></asp:TextBox><br /><br />
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="">
<ItemTemplate>
<asp:Button ID="ButtonAdd2" runat="server" Text="Add another row if needed"
onclick="ButtonAdd2_Click" CssClass="grvAddButton" /><br /><br /><br />
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="">
<ItemTemplate>
<asp:Button ID="spouseDelete" runat="server" Text="Delete" CommandName="Delete"
CssClass="grvDelButton" OnClientClick="return confirm('Are you sure you want to remove this row?')" /> <br /><br /><br />
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:gridview>
</td>
</tr>
</table>
<span style="font-weight:bold;font-size:18px;color:#000000;">3. Name and address of sources of Interest or Dividends of $1,000 or greater of Employee and/or Spouse: </span><br /><br />
<table class="table">
<tr>
<td>
<asp:gridview ID="grvDiv" RowStyle-Wrap="false" GridLines="None" CssClass="responsiveTable1" runat="server" ShowFooter="true" AutoGenerateColumns="false" OnRowDeleting="grvDiv_RowDeleting">
<Columns>
<asp:BoundField DataField="DivsNumber" Visible="false" HeaderText="Row Number" />
<asp:TemplateField HeaderText="Name">
<headerstyle horizontalalign="Left" />
<ItemTemplate>
<asp:TextBox ID="txtdividentname" Text='<%# Eval("dividentName") %>' placeholder="Name of income or divident source..." runat="server" style="width:375px;" class="form-control" AutoPostBack="true" OnTextChanged="txtdividentname_TextChanged"></asp:TextBox><br />
<asp:CheckBox ID="divDetails" runat="server" Checked="false" AutoPostBack="true" OnCheckedChanged="divCheckChanged" /><span style="color:#ff0000">*Check this box if N/A</span>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Address">
<ItemStyle HorizontalAlign="Left"></ItemStyle>
<ItemTemplate>
<asp:TextBox ID="txtdividentaddress" Text='<%# Eval("dividentAddress") %>' placeholder="Address..." runat="server" style="width:375px;" class="form-control"></asp:TextBox><br /><br />
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="">
<ItemTemplate>
<asp:Button ID="ButtonAdd3" runat="server" Text="Add another row if needed"
onclick="ButtonAdd3_Click" CssClass="grvAddButton" /><br /><br /><br />
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="">
<ItemTemplate>
<asp:Button ID="divDelete" runat="server" Text="Delete" CommandName="Delete"
CssClass="grvDelButton" OnClientClick="return confirm('Are you sure you want to remove this row?')" /> <br /><br /><br />
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:gridview>
</td>
</tr>
</table>
<span style="font-weight:bold;font-size:18px;color:#000000;">4. Name and address of sources of reimbursement of expenses of $1,000 or greater of Employee and/or Spouse: (excluding reimbursement of expenses by DeKalb County or reimbursement by any insurance program offered by DeKalb County):</span><br /><br />
<table class="table">
<tr>
<td>
<asp:gridview ID="grvReim" RowStyle-Wrap="false" GridLines="None" CssClass="responsiveTable1" runat="server" ShowFooter="true" AutoGenerateColumns="false" OnRowDeleting="grvReim_RowDeleting">
<Columns>
<asp:BoundField DataField="ReimNumber" Visible="false" HeaderText="Row Number" />
<asp:TemplateField HeaderText="Name">
<headerstyle horizontalalign="Left" />
<ItemTemplate>
<asp:TextBox ID="txtReimbursename" Text='<%# Eval("reimbursementName") %>' placeholder="Name of source of reimbursement..." runat="server" style="width:375px;" class="form-control" AutoPostBack="true" OnTextChanged="txtReimbursename_TextChanged"></asp:TextBox><br />
<asp:CheckBox ID="reimDetails" runat="server" Checked="false" AutoPostBack="true" OnCheckedChanged="ReimCheckChanged" /><span style="color:#ff0000">*Check this box if N/A</span>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Address">
<ItemStyle HorizontalAlign="Left"></ItemStyle>
<ItemTemplate>
<asp:TextBox ID="txtReimburseaddress" Text='<%# Eval("reimbursementAddress") %>' placeholder="Address..." runat="server" style="width:375px;" class="form-control"></asp:TextBox><br /><br />
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField>
<ItemTemplate>
<asp:Button ID="ButtonAd4" runat="server" Text="Add another row if needed"
onclick="ButtonAdd4_Click" CssClass="grvAddButton" /><br /><br /><br />
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="">
<ItemTemplate>
<asp:Button ID="reimnDelete" runat="server" Text="Delete" CommandName="Delete"
CssClass="grvDelButton" OnClientClick="return confirm('Are you sure you want to remove this row?')" /> <br /><br /><br />
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:gridview>
</td>
</tr>
</table>
<span style="font-weight:bold;font-size:18px;color:#000000;">5. Honoraria from a single source in the aggregate amount of $500.00 or greater: (No comma (,) or period(.), eg 500)</span>
<button type="button" class="btn btn-info" data-toggle="popover" title="Honoraria Definition" data-trigger="focus" data-content="A payment given to a professional person for services for which fees are not legally or traditionally required."></button><br />
<table class="table">
<tr>
<td>
<asp:gridview ID="grvHon" RowStyle-Wrap="false" GridLines="None" CssClass="responsiveTable1" runat="server" ShowFooter="true" AutoGenerateColumns="false" OnRowDeleting="grvHon_RowDeleting">
<Columns>
<asp:BoundField DataField="HonNumber" Visible="false" HeaderText="Row Number" />
<asp:TemplateField HeaderText="Honoraria">
<headerstyle horizontalAlign="Left" />
<ItemTemplate>
<asp:TextBox ID="txthonoraria" Text='<%# Eval("honoraria") %>' placeholder="Honoraria from a single source... eg 500" runat="server" style="width:250px;" class="form-control txtgiftincome" AutoPostBack="true" OnTextChanged="txthonoraria_TextChanged"></asp:TextBox><br />
<asp:CheckBox ID="honDetails" runat="server" Checked="false" AutoPostBack="true" OnCheckedChanged="HonCheckChanged" /><span style="color:#ff0000">*Check this box if N/A</span>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Address">
<ItemStyle HorizontalAlign="Left"></ItemStyle>
<ItemTemplate>
<asp:TextBox ID="txthonaddress" Text='<%# Eval("HonorariaAddress") %>' placeholder="Address..." runat="server" style="width:250px;" class="form-control"></asp:TextBox><br /><br />
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Income">
<ItemStyle HorizontalAlign="Left"></ItemStyle>
<ItemTemplate>
<asp:TextBox ID="txthonincome" Text='<%# Eval("HonorariaIncome") %>' placeholder="Income...(example: 500)" runat="server" style="width:250px;" class="form-control txtgiftincome numeric"></asp:TextBox>
<asp:CompareValidator ID="valQtyNumeric" runat="server" ControlToValidate="txthonincome" style="color:red;font-weight:bold;font-size:1.0em;" Display="Dynamic" SetFocusOnError="true"
Text="" ErrorMessage="Error: Amount must be digits only!" Operator="DataTypeCheck" Type="Integer">
</asp:CompareValidator><br /><br />
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField>
<ItemTemplate>
<asp:Button ID="ButtonAdd5" runat="server" Text="Add another row if needed"
onclick="ButtonAdd5_Click" CssClass="grvAddButton" /><br /><br /><br />
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="">
<ItemTemplate>
<asp:Button ID="HonDelete" runat="server" Text="Delete" CommandName="Delete"
CssClass="grvDelButton" OnClientClick="return confirm('Are you sure you want to remove this row?')" /> <br /><br /><br />
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:gridview>
</td>
</tr>
</table>
<span style="font-weight:bold;font-size:18px;color:#000000;">6. Name and address of the source of any gift /or gifts in the aggregate amount or value of $500 or greater from a single source: (excluding gifts from relatives unless the relative is doing business with the County):</span><br /><br />
<table class="table">
<tr>
<td>
<asp:gridview ID="grvGift" RowStyle-Wrap="false" GridLines="None" CssClass="responsiveTable1" runat="server" ShowFooter="true" AutoGenerateColumns="false" OnRowDeleting="grvGift_RowDeleting">
<Columns>
<asp:BoundField DataField="GiftNumber" Visible="false" HeaderText="Row Number" />
<asp:TemplateField HeaderText="Name">
<headerstyle horizontalalign="Left" />
<ItemTemplate>
<asp:TextBox ID="txtgiftname" Text='<%# Eval("giftName") %>' placeholder="Name of source of any gift..." runat="server" style="width:375px;" class="form-control" AutoPostBack="true" OnTextChanged="txtgiftname_TextChanged"></asp:TextBox><br />
<asp:CheckBox ID="giftDetails" runat="server" Checked="false" AutoPostBack="true" OnCheckedChanged="GiftCheckChanged" /><span style="color:#ff0000">*Check this box if N/A</span>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Address">
<ItemStyle HorizontalAlign="Left"></ItemStyle>
<ItemTemplate>
<asp:TextBox ID="txtgiftaddress" Text='<%# Eval("giftAddress") %>' placeholder="Address..." runat="server" style="width:375px;" class="form-control"></asp:TextBox><br /><br />
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField>
<ItemTemplate>
<asp:Button ID="ButtonAdd6" runat="server" Text="Add another row if needed"
onclick="ButtonAdd6_Click" CssClass="grvAddButton" /><br /><br /><br />
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="">
<ItemTemplate>
<asp:Button ID="giftDelete" runat="server" Text="Delete" CommandName="Delete"
CssClass="grvDelButton" OnClientClick="return confirm('Are you sure you want to remove this row?')" /> <br /><br /><br />
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:gridview>
</td>
</tr>
</table>
<span style="font-weight:bold;font-size:18px;color:#000000;">7. Name and address of any organization in which the employee or spouse is an officer, director, partner, proprietor or serves in any advisory capacity from which the income of $1,000.00 or greater was derived:</span><br /><br />
<table class="table">
<tr>
<td>
<asp:gridview ID="grvOrg" RowStyle-Wrap="false" GridLines="None" CssClass="responsiveTable1" runat="server" ShowFooter="true" AutoGenerateColumns="false" OnRowDeleting="grvOrg_RowDeleting">
<Columns>
<asp:BoundField DataField="OrgNumber" Visible="false" HeaderText="Row Number" />
<asp:TemplateField HeaderText="Name">
<headerstyle horizontalalign="Left" />
<ItemTemplate>
<asp:TextBox ID="txtorgname" Text='<%# Eval("orgName") %>' placeholder="Name of organization..." runat="server" style="width:375px;" class="form-control" AutoPostBack="true" OnTextChanged="txtorgname_TextChanged"></asp:TextBox><br />
<asp:CheckBox ID="orgDetails" runat="server" Checked="false" AutoPostBack="true" OnCheckedChanged="OrgCheckChanged" /><span style="color:#ff0000">*Check this box if N/A</span>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Address">
<ItemStyle HorizontalAlign="Left"></ItemStyle>
<ItemTemplate>
<asp:TextBox ID="txtorgaddress" Text='<%# Eval("orgAddress") %>' placeholder="Address..." runat="server" style="width:375px;" class="form-control"></asp:TextBox><br /><br />
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField>
<ItemTemplate>
<asp:Button ID="ButtonAdd7" runat="server" Text="Add another row if needed"
onclick="ButtonAdd7_Click" CssClass="grvAddButton" /><br /><br /><br />
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="">
<ItemTemplate>
<asp:Button ID="orgDelete" runat="server" Text="Delete" CommandName="Delete"
CssClass="grvDelButton" OnClientClick="return confirm('Are you sure you want to remove this row?')" /> <br /><br /><br />
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:gridview>
</td>
</tr>
</table>
<span style="font-weight:bold;font-size:18px;color:#000000;">8. Name and address of each creditor to whom the employee or spouse was indebted for a period of 90 consecutive days or more in an amount of $7,500.00 or greater, excluding the purchase or sale of real property, retail installment debt, vehicle payments and student loans:</span><br /><br />
<table class="table">
<tr>
<td>
<asp:gridview ID="grvCred" RowStyle-Wrap="false" GridLines="None" CssClass="responsiveTable1" runat="server" ShowFooter="true" AutoGenerateColumns="false" OnRowDeleting="grvCred_RowDeleting">
<Columns>
<asp:BoundField DataField="CreditNumber" Visible="false" HeaderText="Row Number" />
<asp:TemplateField HeaderText="Name">
<headerstyle horizontalalign="Left" />
<ItemTemplate>
<asp:TextBox ID="txtcreditorname" Text='<%# Eval("creditorname") %>' placeholder="Name of creditor..." runat="server" style="width:375px;" class="form-control" AutoPostBack="true" OnTextChanged="txtcreditorname_TextChanged"></asp:TextBox><br />
<asp:CheckBox ID="credDetails" runat="server" Checked="false" AutoPostBack="true" OnCheckedChanged="CredCheckChanged" /><span style="color:#ff0000">*Check this box if N/A</span>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Address">
<ItemStyle HorizontalAlign="Left"></ItemStyle>
<ItemTemplate>
<asp:TextBox ID="txtcreditoraddress" Text='<%# Eval("creditoraddress") %>' placeholder="Address..." runat="server" style="width:375px;" class="form-control"></asp:TextBox><br /><br />
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField>
<ItemTemplate>
<asp:Button ID="ButtonAdd8" runat="server" Text="Add another row if needed"
onclick="ButtonAdd8_Click" CssClass="grvAddButton" /><br /><br /><br />
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="">
<ItemTemplate>
<asp:Button ID="credDelete" runat="server" Text="Delete" CommandName="Delete"
CssClass="grvDelButton" OnClientClick="return confirm('Are you sure you want to remove this row?')" /> <br /><br /><br />
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:gridview>
</td>
</tr>
</table>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</asp:View>
</asp:MultiView>
</ContentTemplate>
</asp:UpdatePanel>
</asp:Panel>
</form>
Private Sub fillSourceRecords()
Dim control As Control = Nothing
Dim conn_str As String = ConfigurationManager.ConnectionStrings("ppmtest").ConnectionString
Using conn As SqlConnection = New SqlConnection(ConfigurationManager.ConnectionStrings("ppmtest").ConnectionString)
conn.Open()
Using sourcecmd As SqlCommand = New SqlCommand()
sourcecmd.CommandText = "uspGetEthicsRecs"
sourcecmd.CommandType = CommandType.StoredProcedure
sourcecmd.Parameters.AddWithValue("@empID", txtEmpID.Text.Trim())
sourcecmd.Connection = conn
Using ad As SqlDataAdapter = New SqlDataAdapter(sourcecmd)
Dim ds As DataTable = New DataTable()
ad.Fill(ds)
If ds.Rows.Count > 0 Then
Gridview1.DataSource = ds
Gridview1.DataBind()
grvspouse.DataSource = ds
grvspouse.DataBind()
grvDiv.DataSource = ds
grvDiv.DataBind()
grvReim.DataSource = ds
grvReim.DataBind()
grvHon.DataSource = ds
grvHon.DataBind()
grvGift.DataSource = ds
grvGift.DataBind()
grvOrg.DataSource = ds
grvOrg.DataBind()
grvCred.DataSource = ds
grvCred.DataBind()
Else
End If
End Using
End Using
End Using
End Sub
|
|
|
|
|
You need to remove all the unnecessary code from that post and explain exactly where the error occurs. Please don't just dump everything and leave it to us to try and figure out what you are referring to.
|
|
|
|
|
Thank you sir for your response but you didn't have to respond if the question makes no sense to you.
This is the way you have always responded to any post by anyone.
|
|
|
|
|
|
At a guess (I refuse to wade through your entire code block) you are binding all gridviews to the one collection, you probably need to create a collection for each gridview with only the relevant data in it.
Richards comment is perfectly valid.
Never underestimate the power of human stupidity -
RAH
I'm old. I know stuff - JSOP
|
|
|
|
|
No, his comment is not valid at all.
First of all, I explained the issue that I am having.
If I had done that and not show any code, he would have come back and ask for code.
Most of the code is HTML just to show the many gridview controls I am using and just one method on codebehind which in my view is the code that I believe needs modification.
I am still working on it on my way and if I can get it resolved, I will post it for Richard.
BTW, this is who he is. He is pretty good at yelling at posters but I have not seen any real solution he has provided to any questions here.
Sorry, I don't mean to be mean but I truly dislike when someone yells at you but does not have the ability to help solve your problem.
At least you attempted a solution. I can deal with criticisms if an attempt is made to help if the help doesn't solve your problem.
|
|
|
|
|
The ability to isolate an issue and strip off all which is not relevant is a skill.
A huge lot of unformatted code is just distracting; someone with no knowledge of your issue won't want to wade through all that code to try and find what is the problem and where it lies. Especially when the description of the problem does not immediately make sense.
So we need you to do this primary filtering job. This will allow us to provide better ideas towards resolution. Because, you know, we have lives and jobs, too.
"Five fruits and vegetables a day? What a joke!
Personally, after the third watermelon, I'm full."
|
|
|
|
|
I have not yelled at anyone. I merely suggested that if you want help then you need to help us. You need to understand that we have never seen your code before so have no idea of the thinking or the logic behind it. We rely on you, the poster, to explain in simple terms what the issue is and where it occurs. Without that information we are floundering in the dark.
|
|
|
|
|
Instead of binding all gridviews to one DataTable, bind each grid to a different dataView of the same DataTable:
e.g.
Gridview1.DataSource = New DataView(ds)
Gridview1.DataBind()
grvspouse.DataSource = New DataView(ds)
grvspouse.DataBind()
grvDiv.DataSource = New DataView(ds)
grvDiv.DataBind()
...
...
|
|
|
|
|
Hi Sir,
Need help, i noob in Asp.net. Using VB for my coding;
Situation :-
a) Using Master Page
b) Got 3 web Form ( Staff.aspx,student.aspx,external.aspx)
c) Every form have Search Textbox
In Staff.aspx, search Textbox working great when connecting to Oracle Database and appear the data holder in other textbox.
But when using Student.aspx or External.aspx, the Search Textbox will appear No Data / Cardholder , in database the data is exist.
the Sql query it ok when i direct include the User ID but when keep in in textbox cannot appear the data.
Plz guide me
Tq
|
|
|
|
|
kerek2 wrote: Plz guide me In what way? We have no idea what your code does or what the error is. Please edit your question and show some proper details of the problem.
|
|
|
|
|
I need help to fix an issue where when data from web application is exported to Excel by clicking a button export to excel, if the data in a cell contains double quotes, that data should be displayed without the double quotes visible.
Also I want preceding zeros not to be removed e.g. 081 should not be exported to Excel as 81. This is why I have the line of code sw.Write("=""" & row(column).ToString().Trim() & """" & vbTab)
Previously I made a change to the application code in VB so that the output exports text fields with formulas (="") to force Excel to treat those values as a string. This has been working except some instances where the output actually displays the formula characters (="") within the cell as text, rather than as hidden formulas. It appears when a cell contains text with an actual double quotes that is when after export to Excel is done, those quotes appear in Excel. I need help to figure out if there is a way to suppress those.
For example. A cell with the following data Allows the user the abilities to Add, View, Modify and Delete Notes on the Notes Tab of the Case Record. "View" allows the user to view the Notes Tab of the Case Record.
When this is exported to Excel the data is displayed as follows ="Allows the user the abilities to Add, View, Modify and Delete Notes on the Notes Tab of the Case Record. "View" allows the user to view the Notes Tab of the Case Record. I do not want to quotes to appear in Excel.
On the other hand, a cell with the following data Maintain Victim Classification Types. when this is exported to Excel there are no visible quotes. It displays as Maintain Victim Classification Types.
Here is my VB code that needed changing
Protected Sub WriteToExcelFile(dt As DataTable)
If Not dt Is Nothing Then
Dim sw As New StringWriter()
For Each datacol As DataColumn In dt.Columns
sw.Write(datacol.ColumnName + vbTab)
Next
Dim row As DataRow
For Each row In dt.Rows
sw.Write(vbNewLine)
Dim column As New DataColumn()
For Each column In dt.Columns
If Not row(column.ColumnName) Is Nothing Then
sw.Write("=""" & row(column).ToString().Trim() & """" & vbTab)
Else
sw.Write(String.Empty + vbTab)
End If
Next column
Next row
Response.Clear()
Response.ContentType = "application/vnd.ms-excel"
Response.AddHeader("Content-Disposition", "attachment;filename=GridViewExport.xls")
Response.Output.Write(sw.ToString())
Response.Flush()
System.Web.HttpContext.Current.Response.Flush()
System.Web.HttpContext.Current.Response.SuppressContent = True
System.Web.HttpContext.Current.ApplicationInstance.CompleteRequest()
End If
End Sub
modified 25-Feb-20 10:56am.
|
|
|
|
|
I still need help with this one please
modified 25-Feb-20 10:00am.
|
|
|
|
|
|
I'm implementing asp.net core MVC project. In my controller class called ApiApplicant, Create method, I have 3 selectlists that its items should be populated from a table called APIApplicantHistory. My models and create method and view are implemented like following:
using System.Collections.Generic;
namespace CSDDashboard.Models
{
public partial class Apiapplicant
{
public Apiapplicant()
{
ApiApplicantHistory = new HashSet<apiapplicanthistory>();
}
public int Id { get; set; }
public string ApiRequestDate { get; set; }
public int? ApiRequestNo { get; set; }
public int? Apiid { get; set; }
public int? ApplicantId { get; set; }
public int? GateId { get; set; }
public string NocRequestDate { get; set; }
public string NocRequestNo { get; set; }
public string Url { get; set; }
public string Description { get; set; }
public bool? IsDeleted { get; set; }
public virtual Api Api { get; set; }
public virtual Applicant Applicant { get; set; }
public virtual Gate Gate { get; set; }
public virtual ICollection<apiapplicanthistory> ApiApplicantHistory { get; set; }
}
}
using System;
using System.Collections.Generic;
namespace CSDDashboard.Models
{
public partial class ApiApplicantHistory
{
public int Id { get; set; }
public int? ApiApplicantId { get; set; }
public string Date { get; set; }
public int? SentResponseType { get; set; }
public int? UnconfirmedReason { get; set; }
public int LastReqStatus { get; set; }
public string Description { get; set; }
public virtual Apiapplicant ApiApplicant { get; set; }
public virtual EntityType LastReqStatusNavigation { get; set; }
public virtual EntityType SentResponseTypeNavigation { get; set; }
public virtual EntityType UnconfirmedReasonNavigation { get; set; }
}
}
using System;
using System.Collections.Generic;
namespace CSDDashboard.Models
{
public partial class EntityType
{
public EntityType()
{
ApiApplicantHistoryLastReqStatusNavigation = new HashSet<apiapplicanthistory>();
ApiApplicantHistorySentResponseTypeNavigation = new HashSet<apiapplicanthistory>();
ApiApplicantHistoryUnconfirmedReasonNavigation = new HashSet<apiapplicanthistory>();
}
public int Id { get; set; }
public string Name { get; set; }
public string EntityKey { get; set; }
public virtual ICollection<apiapplicanthistory> ApiApplicantHistoryLastReqStatusNavigation { get; set; }
public virtual ICollection<apiapplicanthistory> ApiApplicantHistorySentResponseTypeNavigation { get; set; }
public virtual ICollection<apiapplicanthistory> ApiApplicantHistoryUnconfirmedReasonNavigation { get; set; }
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
namespace CSDDashboard.Models
{
public class APIApplicantViewModel
{
public Apiapplicant apiApplicantvm { get; set; }
public ApiApplicantHistory apiApplicantHistoryvm { get; set; }
}
}
public class ApiapplicantsController : Controller
{
private readonly CSSDDashboardContext _context;
public ApiapplicantsController(CSSDDashboardContext context)
{
_context = context;
}
public IActionResult Create()
{
ViewData["sentResponseType"] = new SelectList(_context.EntityType.Where(g => g.EntityKey == "sentResponseType")
.Include(x => x.ApiApplicantHistoryLastReqStatusNavigation).ToList(), "ID", "name");
ViewData["unconfirmedReason"] = new SelectList(_context.EntityType.Where(g => g.EntityKey == "unconfirmedReason").ToList(), "ID", "name");
ViewData["lastReqStatus"] = new SelectList(_context.EntityType.Where(g => g.EntityKey == "lastRequestStatus").ToList(), "ID", "name");
return View();
}
}
And a part of create view implementation:
@modelCSDDashboard.Models.APIApplicantViewModel
@{
ViewData["Title"] = "create";
}
@section Scripts {
@{await Html.RenderPartialAsync("_ValidationScriptsPartial");}
}
In create method, all the viewData are filled with the correct related data but the problem is existing in Create view, after running the project an error like below is shown in Create page:
An unhandled exception occurred while processing the request.
NullReferenceException: Object reference not set to an instance of an object.
After debugging the code I understand that In create view, apiApplicantvm is not null but
ViewBag.sentResponseType returns null and the above error is because of that. I appreciate if anyone could tells me how to fix the problem.
|
|
|
|
|
many time i create action in controller and decorate them with HttpGet or HttpPost verb and call those action by jquery ajax and action return json to client side. i got no difference when i change from HttpGet or HttpPost for any specific action.
so i am curious to know when i should use only HttpGet verb and when HttpPost verb for actions in controller ?
also tell me the difference between response travel in case of HttpGet or HttpPost ?
i know the difference between Get & Post
------------------------------------------
Both GET and POST method is used to transfer data from client to server in HTTP protocol but Main difference between POST and GET method is that GET carries request parameter appended in URL string while POST carries request parameter in message body which makes it more secure way of transferring data
but do not aware the difference between HttpGet or HttpPost verb. so please discuss with a example action which guide me when to use HttpGet and when to use HttpPost.
waiting for good guide line. thanks
|
|
|
|
|
I use HTTPGET when I send a URL with parameters such as
https://website.com/api/store/getOrder/1009
and ask for data.
With HTTPPost, I use that when I'm sending a chunk of data such as submitting a form.
https://website.com/api/store/submitOrder
The controller can send back a true or false, or a chunk of data, such as the completed order with order number.
As your request to the api/controller get more complicated, you will see the api/controller not respond to calls if the http protocol is not correct.
If it ain't broke don't fix it
Discover my world at jkirkerx.com
|
|
|
|
|
I saw we can design any action with httpGet or httpPost which return json resultset. so it is not clear to me when httpGet will be appropriate and when httpPost ?
suppose I am calling action which take no parameter rather action return data in json format. so in this case I can decorate action with httpGet or httpPost make no difference. so I like to know real usage of httpGet and httpPost when action taking no data rather return data in json format.
we know that data travel from client to server side bit different way in case of httpGet and httpPost.
for httpGet data pass as query string and for httpPost data pass as message body to server side.
if possible please tell me in case of httpGet how responses travel from server side to client side ?
and same way how responses travel from server side to client side in case of httpPost ?
thanks
|
|
|
|
|
HttpPost and HttpGet simply mean you allow those methods to be called via that verb. It doesn't change anything about how the client works or how data is transmitted. Whether you use GET or POST depends on the calling code, the action attributes simply say which ones are allowed. If you put only HttpPost on a method and try to call that via GET on the client, you'll get a failure code back. If you have HttpGet and HttpPost on a method then then client can use GET or POST, but again that is up to the client to decide which one is used.
In terms of server to client, there is no difference between GET and POST.
Which you should use depends on the semantics of what your method does. If you are retrieving info, like Customer 123, then use GET, if you are sending data to the server for storage then use POST. Also remember that GET and POSt are remnants of how browsers request URLs, there are other verbs you can use depending on what you are doing. Again which one you use depends on the semantics of what your method is doing.
HTTP Methods for RESTful Services[^]
The other thing you might want to consider is that GETs can be cached but POSTs will never be cached.
|
|
|
|
|
Sir you said -- In terms of server to client, there is no difference between GET and POST.
we all know there is difference between Get & POST when we send data from client to server. in case Get data pass from client to server as query string and in case of Post data pass from client to server as message body.
so when a ASP.Net MVC action decorated with Get or POST return data from server to client same way as you said if we use Get or Post...am i right ?
|
|
|
|
|
|
|
Another thing to consider: don't use GET for actions which modify data.
GET requests should be idempotent - there should be no difference between making the request once or making the request forty two times.
If the action creates, updates, or deletes data, then use the POST , PUT , or DELETE methods. If the client doesn't support PUT or DELETE , then just use POST .
HTTP Methods – REST API Verbs – REST API Tutorial[^]
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
i am talking about data passing from server side to client side when we can a action by jquery ajax.
any difference would be there for transmitting data from server to client if action is decorated with Get or Post verb?
@F-ES Sitecore replied in same thread that In terms of server to client, there is no difference between GET and POST.
do you agree with it? i do not know that is why i am asking? because every one has different views.
thanks
|
|
|
|
|
Tbh at first, I was also confused by F-ES Sitecore's statement. But then I've noticed at the very end of his message
Quote: The other thing you might want to consider is that GETs can be cached but POSTs will never be cached.
which is implied from the abovementioned HTTP Verb semantics (GET is for querying data which might be cached, while POST is indeed a non-idempotent creating operation, so it makes no sense caching it).
|
|
|
|
|