Logo 
Search:

Asp.net Answers

Ask Question   UnAnswered
Home » Forum » Asp.net       RSS Feeds
  Question Asked By: Zobah Mizrachi   on Dec 18 In Asp.net Category.

  
Question Answered By: Liam Bouchard   on Dec 18

Yes, the error that I am getting when the page first
loads is this:
Object reference not set to an instance of an object.

Also here is a more complete code set.


Protected Sub Page_Load(ByVal sender As System.Object,
ByVal e As System.EventArgs) Handles MyBase.Load
Dim ConnectString As String
MyConnect = New SqlConnection()
ConnectString =
ConfigurationSettings.AppSettings("ConnectStr")
MyConnect.ConnectionString = ConnectString
'Lbl_Biller.Text =
Convert.ToString(Session("UserCode"))
If Not IsPostBack Then
BindGrid()
Collections()
Else

End If
End Sub

Protected Sub BindGrid()
Dim strSQL As String = "Select top 5 * From
vCollectionQForms" & _
" Where DOS is not
null" & _
" or Priority is not
null" & _
" or Status is not null
Order by Priority asc"
Dim MyCommand As SqlDataAdapter = New
SqlDataAdapter(strSQL, MyConnect)
Dim CollectionQDS As DataSet = New DataSet()
MyCommand.Fill(CollectionQDS, "CollectionQ")
CollectionQDataGrid.DataSource = CollectionQDS
CollectionQDataGrid.DataBind()
Dim Row1 As DataRow =
CollectionQDS.Tables("CollectionQ").Rows(0)
Lbl_AccountNum.Text =
Row1("ACCOUNTNUM").ToString()
Lbl_DOS.Text = Format(Row1("DOS"),
"d").ToString()
Lbl_PatientName.Text =
Row1("PatientName").ToString()
Lbl_Priority.Text =
Row1("Priority").ToString()
Lbl_TodayStatus.Text =
Row1("Status").ToString()
Lbl_PatientAge.Text = Row1("Age").ToString()
Lbl_ResponsParty.Text =
Row1("Subscriber").ToString()
Lbl_PrimaryInsure.Text =
Row1("CarrierNam").ToString()
'Lbl_SecInsure.Text =
Row1("PayorName").ToString()
End Sub

Protected Sub Collections()
MyConnect.Open()
Dim strSQL As String = "Select *,
QTY1*CHARGES1 As StdFee," & _
"AllowableAmt - insurancepaid As InsureVar "
& _
"from tCollectionQ " & _
"where ACCOUNTNUM = " & _
Lbl_AccountNum.Text & "and DOS='" &
Lbl_DOS.Text & "'"
Dim objAdapter As SqlDataAdapter = New
SqlDataAdapter(strSQL, MyConnect)
Dim CollectionQDS As DataSet = New DataSet()
objAdapter.Fill(CollectionQDS,
"CollectionQinfo")
Dim dRow As DataRow =
CollectionQDS.Tables("CollectionQinfo").Rows(0)
CollectionsTable.DataSource =
CollectionQDS
CollectionsTable.DataBind()


Dim SQLCommand As New SqlCommand(strSQL,
MyConnect)
Dim SQLReader = SQLCommand.ExecuteReader()
CollectionsTable.DataSource = SQLReader
CollectionsTable.DataBind()
SQLReader.close()
MyConnect.Close()
End Sub

Protected Sub InsurDropDown()
'MyConnect.Open()
Dim AddChoice As ListItem
Dim MyCommand = New SqlCommand("Select * From
tCollectionAction where Type = 1 or Type = 0",
MyConnect)
oReader = MyCommand.ExecuteReader()
DD_InsurPayAction.DataSource = oReader
DD_InsurPayAction.DataBind()
MyConnect.Close()
AddChoice = New ListItem("Select Insurance
Payment Action", "0")
AddChoice.Selected = True
If Not
DD_InsurPayAction.Items.Contains(AddChoice) Then
DD_InsurPayAction.Items.Insert(0,
AddChoice)
End If
End Sub

Protected Sub PatientDropDown()
MyConnect.Open()
Dim AddChoice As ListItem
Dim MyCommand = New SqlCommand("Select * From
tCollectionAction where Type = 2 or Type = 0",
MyConnect)
oReader = MyCommand.ExecuteReader()
DD_PatPayAction.DataSource = oReader
DD_PatPayAction.DataBind()
MyConnect.Close()
AddChoice = New ListItem("Select Patient
Payment Action", "0")
AddChoice.Selected = True
If Not
DD_PatPayAction.Items.Contains(AddChoice) Then
DD_PatPayAction.Items.Insert(0, AddChoice)
End If
End Sub

Protected Sub CoPayDropDown()
MyConnect.Open()
Dim AddChoice As ListItem
Dim MyCommand = New SqlCommand("Select * From
tCollectionAction where Type = 3 or Type = 0",
MyConnect)
oReader = MyCommand.ExecuteReader()
DD_CoPayAction.DataSource = oReader
DD_CoPayAction.DataBind()
MyConnect.Close()
AddChoice = New ListItem("Select Co-Payment
Action", "0")
AddChoice.Selected = True
If Not
DD_CoPayAction.Items.Contains(AddChoice) Then
DD_CoPayAction.Items.Insert(0, AddChoice)
End If
End Sub

Protected Sub Btn_Save_Click(ByVal sender As
System.Object, ByVal e As System.EventArgs)
Dim Adapter As SqlDataAdapter = New
SqlDataAdapter()
Dim EditCB As SqlCommandBuilder
Dim EditDS As DataSet = New DataSet()
Dim Row As DataRow
ConnectString =
ConfigurationSettings.AppSettings("ConnectStr")
MyConnect.ConnectionString = ConnectString
Adapter.SelectCommand = New SqlCommand("Select
* from tCollectionCurrent where AcctNum = " & _
Lbl_AccountNum.Text & " and DOS =
'" & Lbl_DOS.Text & "'", MyConnect)
EditCB = New SqlCommandBuilder(Adapter)
Adapter.Fill(EditDS, "CurrentCollection")

Row =
EditDS.Tables("CurrentCollection").Rows(0)

Row.Item("AcctNum") = Lbl_AccountNum.Text
Row.Item("DOS") = Lbl_DOS.Text
Row.Item("Status") = "2"
Row.Item("Priority") = "B"
Row.Item("InsuranceStatus") =
DD_InsurPayAction.SelectedItem.Value
Row.Item("PatientPmtStatus") =
DD_PatPayAction.SelectedItem.Value
Row.Item("CoPayStatus") =
DD_CoPayAction.SelectedItem.Value
Adapter.Update(EditDS, "CurrentCollection")

If EditDS.HasErrors Then
Lbl_Message.Text = "There was an error
Updating Current History Information, Please try
again." & _

EditDS.Tables("GetUser").Rows(0).RowError
Else
BindGrid()
Collections()
WriteCollectionHistory()

End If
End Sub

Sub WriteCollectionHistory()
Dim CollectionHistoryDS As DataSet = New
DataSet()
Dim CollectionHistoryCB As SqlCommandBuilder
Dim ConnectString As String
Dim Connect As SqlConnection = New
SqlConnection()
Dim Adapter As SqlDataAdapter = New
SqlDataAdapter()
Dim Row As DataRow
ConnectString =
ConfigurationSettings.AppSettings("ConnectStr")
Connect.ConnectionString = ConnectString
Adapter.SelectCommand = New SqlCommand("Select
* from tCollectionHistory", Connect)
CollectionHistoryCB = New
SqlCommandBuilder(Adapter)
Adapter.Fill(CollectionHistoryDS,
"CollectionHistory")
Row =
CollectionHistoryDS.Tables("CollectionHistory").NewRow
Row.Item("AcctNum") = Lbl_AccountNum.Text
Row.Item("DOS") = Lbl_DOS.Text
Row.Item("TranDate") = Now()
Row.Item("UserID") =
Convert.ToString(Session("UserCode"))
Row.Item("Status") = "2"
Row.Item("Priority") = "B"
Row.Item("InsuranceDD") =
DD_InsurPayAction.SelectedItem.Value
Row.Item("PatientDD") =
DD_PatPayAction.SelectedItem.Value
Row.Item("CoPayDD") =
DD_CoPayAction.SelectedItem.Value

CollectionHistoryDS.Tables("CollectionHistory").Rows.Add(Row)
Adapter.Update(CollectionHistoryDS,
"CollectionHistory")
If CollectionHistoryDS.HasErrors Then
Lbl_Message.Text = "There was an error
inserting Collection History Record." & _

CollectionHistoryDS.Tables("CollectionHistory").Rows(0).RowError
End If
End Sub

Protected Sub AttachDropdowns(ByVal S As Object,
ByVal e As RepeaterItemEventArgs)
'Dim InusurDD As dropdownlist  =
e.Item.FindControl("DD_InsurPayAction")
'Dim PatientDD As DropDownList =
e.Item.FindControl("DD_PatPayAction")
'Dim CoPayDD As DropDownList =
e.Item.FindControl("DD_CoPayAction")
InsurDropDown()
PatientDropDown()
CoPayDropDown()
End Sub

Here is my HTML and Web Controls for the footer in the
repeater:

<FooterTemplate>
<tr>
<td align="right" colspan="4">
<asp:button id="Btn_Save"
onclick="Btn_Save_Click" Runat="server"
Text="Save"></asp:button></td>
<td colspan="3" align="middle">
<asp:dropdownlist ID="DD_InsurPayAction"
Font-Size="8" DataValueField="BillingActionID"
DataTextField="BillingActionDescription"
runat="server" /></td>
<td colspan="3" align="middle">
<asp:dropdownlist ID="DD_PatPayAction"
Font-Size="8" DataValueField="BillingActionID"
DataTextField="BillingActionDescription"
runat="server" /></td>
<td colspan="3" align="middle">
<asp:dropdownlist ID="DD_CoPayAction"
Font-Size="8" DataValueField="BillingActionID"
DataTextField="BillingActionDescription"
runat="server" /></td>
</tr>
</table>
</FooterTemplate>
</asp:repeater>

Share: 

 

This Question has 9 more answer(s). View Complete Question Thread

 
Didn't find what you were looking for? Find more on Dropdown nested in repeater Or get search suggestion and latest updates.


Tagged: