473,804 Members | 3,138 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Losing ddl and repeater items on postback

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
Nov 19 '05 #1
1 2713
I just realised that I had set the AutoPostBack property to true in
design view for the ddl. One problem solved.

Nov 19 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
2739
by: anon | last post by:
I am having a hard time with makeing what I am trying to do work. I am making a questionaire web app. I have a custom control that has a label and 5 radio buttons. My problem is that each different topic for the questionaire is in a database and each questionaire will have a different number of questions. I am trying to use a repeater to creat multiple copies of the control, unfortunately when I do this the different controls act like...
8
4282
by: Invalidlastname | last post by:
Hi, We are developing an asp.net application, and we dynamically created certain literal controls to represent some read-only text for certain editable controls. However, recently we found an issue which is related to the repeater. In the code shown below, if I call Repeater1.Controls.Count in the OnInit (the code fragment was highlighted in yellow) , the viewstate for the repeater will be lost during the postback. You can re-produce this...
3
3934
by: Kevin Cunningham | last post by:
I have a repeater with some labels in it (code below). For whatever reason the text for the label is not persisted in viewstate on the postback. Is there a trick to get this to work? Is there something else I can do to get the same visual effect (not using a datagrid :) )? This is annnooying! <table> <asp:repeater id="rptGunReadingsNew" runat="server"> <ItemTemplate> <tr> <td>
4
1980
by: Dave | last post by:
Well... with data in the textbox.. This did not work... <asp:TableCell ID="Tablecell1" CssClass="lnk_results" Runat="server" Width="35%" HorizontalAlign="Left" ColumnSpan="5"> <asp:TextBox id="TextBoxMessage" runat="server" TextMode="MultiLine" Width="248px" Height="80px"><%# DataBinder.Eval(Container.DataItem, "Item_Description") %></asp:TextBox>
1
2334
by: Andy | last post by:
team, my postback is changing once i bind an arraylist to a repeater. how can i get the postback to return true? ''''''''''''''''''''''''''''''''''''''''' 'declarations
1
17050
by: Timbo | last post by:
Hi all, This is my first message here so i'll try and include all the information that will help you help me out, if possible. Basically I am using C# in ASP.NET 2.0 and have a Repeater control in my aspx page with two image buttons, one for an edit command, another a delete command. Here is a cut down code fragment. ...
2
4833
by: Nemo | last post by:
Hi, I have i fishy problem when I have e Repeater with user controls. page_load { if (!isPostBack) { repeater.databind(); }
1
2705
by: Jeremy | last post by:
Hello All, I have a Repeater which contains a Dynamic DropDownList within its itemtemplate. I know I have struggled with this before and I am pretty sure I had to save a bunch of crap manually to the viewstate, but does anyone know what would cause those DropDownList objects to clear out on postback. Is there a setting on the Repeater I am forgetting about? I tried tooling with EnableViewState but that did not work. The Repeater gets...
1
2563
by: supraracer | last post by:
Can anyone show me an example of a solution to the problem described in this thread? How do I rebind a label in a repeater on a postback? http://bytes.com/groups/net-asp/327013-label-within-repeater-losing-text-post-back (I don't seem to be able to post to that group or something). Thanks.
0
9579
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10575
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10330
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
7616
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6851
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5520
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5651
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4297
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2990
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.