Logo 
Search:

Asp.net Forum

Ask Question   UnAnswered
Home » Forum » Asp.net       RSS Feeds

repeater update data problem

  Asked By: Sean    Date: Jan 06    Category: Asp.net    Views: 6642
  

I have a repeater and inside my repeater I have
displayed some information from the database. In my
footer I have a dropdown box and a save button. The
user can select something from the dropdown and click
the save button to write to the database.

My problem is when the save button is clicked I get an
object referrence error. I can't figure out why this
is happening. Here is my code. It errors out on this
line:


Row.Item("InsuranceStatus") =
CType(FindControl("DD_InsurPayAction"),
DropDownList).SelectedItem.Value



Protected Sub Btn_Save_Click(ByVal sender As 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
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") =
CType(FindControl("DD_InsurPayAction"),
DropDownList).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

Share: 

 

6 Answers Found

 
Answer #1    Answered By: Hoor Khan     Answered On: Jan 06

The typename function will help you track this down...


trace.warn("Update typename", typename(FindControl("DD_InsurPayAction"))
before the assignment.

Add <%@ trace="true"%>
to top of page.

 
Answer #2    Answered By: Hugo Williams     Answered On: Jan 06

It pumped out the following in
red but I don't know what it is telling me.


Update typename Nothing 0.618580 0.613394
Unhandled Execution Error
Object reference not set to an instance of an object.
at Pace.CollectionsQ.Btn_Save_Click(Object sender,
EventArgs e) in
c:\inetpub\wwwroot\Pace\CollectionsQ.aspx.vb:line 192
at
System.Web.UI.WebControls.Button.OnClick(EventArgs e)
at
System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBa\
ckEvent(String
eventArgument)
at
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler
sourceControl, String eventArgument)
at
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection
postData)
at System.Web.UI.Page.ProcessRequestMain()

 
Answer #3    Answered By: Amelia Schmidt     Answered On: Jan 06

Nothing means it could not find the control.

probably
[repeatername].findcontrol()
will work better than findcontrol()

 
Answer #4    Answered By: Kristen Chavez     Answered On: Jan 06

Still having the same problem  even after I tried Using
CollectionsTable.findcontrol. I am at a loss. Have any
other ideas for solving this problem.

 
Answer #5    Answered By: Jennie Harris     Answered On: Jan 06

I got it!
e.item.findcontrol.

 
Answer #6    Answered By: Melissa King     Answered On: Jan 06

I have to add that that will only work purely because there is only a single row
in the footer, thus NO duplicates are made when rows are created.
And that is why I didn't suggest it earlier, it eluded me.
I was thinking you were trying to save data  from combo's ot textboxes within the
items template - as well as saving combo's stuff from the footer - all at the
click of save  button.

[[
This has also tought me something about FindControl() that I did not know and
must now look into.
(normally you can use any control to boot up FindControl(), since
x.FindControl("hh") and y.FindControl("hh") will find the same control "hh" as
it looks for "hh" in general ... AND NOT child controls named "hh" within x or
child controls names "hh" within y.
Here however the e.Item.FindControl(" ") is needed.
But don't quote me.
]]

 
Didn't find what you were looking for? Find more on repeater update data problem Or get search suggestion and latest updates.




Tagged: