I have a ddl that is populated in my If Not IsPostBack block in the
Page_load event. A repeater is also populated at this time, showing
different domains for a website. The ddl contains different price
plans that can be selected.
My problem is that the user has a choice of being able to update
information, or update and create a new domain. In doing either, if
the user changes the index of the ddl, I lose all data in the ddl, and
my repeater disappears, also. I cannot understand why it is happening.
I have tried having my binddatagrid() function call in the Not
IsPostBack block alone, I have tried coupling it with another call in
the ddl_SelectedInd exChanged event, and also with it in the update
call. I will post my code below.
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As
System.EventArg s) Handles MyBase.Load
'pull the domain id from session, and query the domain db, and
bind the dropdown list
'also stores the name of the client from session, in a textbox
If Not IsPostBack Then
domainID = Session("domain ID")
websiteID = Session("websit eID")
Website.Value = websiteID
binddropdownlis t()
doPaging(websit eID)
PopulateTextBox es(websiteID)
btnUpdate.Attri butes.Add("onCl ick",
"javascript:ret urn(confirmatio n());")
Else
Session.Add("do mainID", domainID)
Session.Add("we bsiteID", websiteID)
End If
lblClientName.T ext = Session("client _name")
Session("websit e_id") = Request("websit e")
End Sub
Private Sub binddropdownlis t()
Dim cmdDDL As New SqlCommand("stp _registrar_plan _dropdown",
connection)
Dim dsDDL As New DataSet
connection.Open ()
cmdDDL.CommandT ype = CommandType.Sto redProcedure
Dim daDDL As New SqlDataAdapter( cmdDDL)
daDDL.Fill(dsDD L, "stp_registrar_ plan_dropdown")
ddlPlan.DataSou rce = dsDDL
ddlPlan.DataMem ber = "stp_registrar_ plan_dropdown"
ddlPlan.DataTex tField = "plan_descripti on"
ddlPlan.DataVal ueField = "plan_id"
ddlPlan.DataBin d()
connection.Clos e()
End Sub
Private Sub btnUpdate_Click (ByVal sender As System.Object, ByVal e
As System.EventArg s) Handles btnUpdate.Click
Dim websiteID As String = Request("websit e")
Dim cmdUpdateNameAn dComments As New SqlCommand("upd ate
t_website_id set name = '" & txtWebsiteName. Text & "', comments = '" &
txtWebsiteComme nts.Text & "' " _
& "where
website_id = '" & websiteID & "'", connection)
connection.Open ()
cmdUpdateNameAn dComments.Execu teNonQuery()
connection.Clos e()
doPaging(websit eID)
PopulateTextBox es(websiteID)
Dim tempWebID As String
Dim tempID As String = Session("tempID ")
Dim cmdFind As New SqlCommand("Sel ect * from t_website_id
where id = '" & tempID & "'", connection)
Dim dsFind As New DataSet
Dim yesNo As Integer = Request("newDom ain")
connection.Open ()
Dim daFind As New SqlDataAdapter( cmdFind)
daFind.MissingS chemaAction = MissingSchemaAc tion.AddWithKey
daFind.Fill(dsF ind, "t_website_ id")
Dim dr As DataRow
For Each dr In dsFind.Tables(" t_website_id"). Rows
If dr("website_id" ) = websiteID Then
tempWebID = dr("website_id" )
End If
Next
Dim cmdInsertPlan As New SqlCommand("ins ert into
t_website_hosti ng_plan(website _id, plan_id, auto_renew) values('" &
websiteID & "', '" & ddlPlan.Selecte dItem.Value & "', '1')",
connection)
cmdInsertPlan.E xecuteNonQuery( )
'This is from a js function that checks to see if they want to create
'a new domain also, or just update the information
If yesNo = 0 Then
Dim domain As String = "update t_domain_id set domain =
'', registrar = '', create_date = '" & Now.Date & "', website_id = '"
& tempWebID & "' " _
& "WHERE website_id = '" & tempWebID
& "'"
Dim cmdAddDomain As New SqlCommand(doma in, connection)
cmdAddDomain.Ex ecuteNonQuery()
Dim dsDomain As New DataSet
Dim cmdDomain As New SqlCommand("Sel ect * from t_domain_id
where website_id = '" & tempWebID & "'", connection)
cmdDomain.Comma ndType = CommandType.Tex t
Dim daDomain As New SqlDataAdapter( cmdDomain)
daDomain.Fill(d sDomain, "t_domain_i d")
Dim tempDomainID As String
For Each dr In dsDomain.Tables ("t_domain_id") .Rows
tempDomainID = dr("domain_id" )
Next
Session.Add("we bsiteID", tempWebID)
Session.Add("do mainID", tempDomainID)
Server.Transfer ("client_domain _modify.aspx", True)
Else
Dim update As String = "update t_website_id set name = '"
& txtWebsiteName. Text & "', comments = '" & txtWebsiteComme nts.Text &
"' " _
& "where website_id = '" & tempWebID &
"'"
Dim cmdUpdate As New SqlCommand(upda te, connection)
cmdUpdate.Execu teNonQuery()
Session.Add("we bsiteID", tempWebID)
Server.Transfer ("client_websit e_list.aspx")
End If
connection.Clos e()
End Sub
Like I said above, I have tried a few different things with my binding
call, and either I get no data and no repeater when the
selectedindexch anged even fires, or I get the Object Reference not set
to an instance of an object error.
Any help would be appreciated!
TIA,
Matthew