473,382 Members | 1,353 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

ListBox AutoPostBack Error

ben
Hi All,
I have a Listbox which gets populated from the database.On selecting
an item in the list, i would like to populate some other
fields......it was working fine until i added
autopostback="true"...now it gives me an error saying"Object does not
support this method or property( IE Script error)
If i remove the AutoPostBack="true", then the error does not
appear....

Code SNippets Follow:

string selecttext="select cUserID,(cFirstname+' '+cLastName) fullName
from tblUser ;
DataTable dataTable = new DataTable();
SqlDataAdapter mydataAdapter=new SqlDataAdapter();
mydataAdapter.SelectCommand=mycommand;
mydataAdapter.Fill(dataTable);
lb1.DataSource=dataTable;
lb1.DataTextField="fullName";
lb1.DataValueField="cUserID";
lb1.DataBind();
public void lb1_SelectedIndexChanged(object sender, System.EventArgs
e)
{
string connstr=ConfigurationSettings.AppSettings["ConnectionString"];
string selecttext="select Firstname,LastName from tblUser where
cUserID="+lb1.SelectedItem.Value;
SqlConnection con=new SqlConnection(connstr);
SqlCommand mycommand=new SqlCommand(selecttext,con);
con.Open();
SqlDataReader dr= mycommand.ExecuteReader();
while(dr.Read())
{
txtfname.Text=dr["FirstName"].ToString();
txtlname.Text=dr["LastName"].ToString();

}
}

<asp:listbox id="lb1" runat="server" Height="216px" Width="178px"
SelectionMode="Single"
AutoPostBack="True" OnSelectedIndexChanged="lb1_SelectedIndexChanged"> </asp:listbox>
ANy help is appreciated,
Thanks,
Ben
Nov 18 '05 #1
2 1760


resolved!

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 18 '05 #2

Could you tell me how you resolved this problem?
I am having the same one with dropdownlists

You may reply to my email directly (it would actually ne nicer for me)
ia*****@freemail.gr

Thank you
--
ias0nas
------------------------------------------------------------------------
ias0nas's Profile: http://www.highdots.com/forums/m1610
View this thread: http://www.highdots.com/forums/t644883

Dec 20 '05 #3

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

Similar topics

1
by: Vengeance | last post by:
On the parent_form.aspx I have these controls <asp:listbox id="Operators" runat="server" Width="163px" SelectionMode="Multiple" Rows="2"></asp:listbox> <INPUT class="loButton" onclick="java...
10
by: yop | last post by:
All When I try to get the text from my listbox I am get an error which is listed below. Any ideas? Thanks Object reference not set to an instance of an object.
2
by: Allan Horwitz | last post by:
When I try to reference the lstproducts.selecteditem.value using autopostback from the lstproducts listbox I get an error? How can I fix my code to get the selected value from the lstproducts...
1
by: Edward | last post by:
I am having a terrible time getting anything useful out of a listbox on my web form. I am populating it with the results from Postcode lookup software, and it is showing the results fine. What...
2
by: DC Gringo | last post by:
I have two listboxes, the first of which is an autopostback=true that allows multiple row selection. When I select multiple values (by holding down CTL) in the first one, it should query the...
1
by: Daniel | last post by:
hi, I had an asp:listbox, and everytime i click item inside, the bar automatically go to the top, is there any way to keep the scroll position? I turn on the smartNavigation, it still doesn't...
4
by: Moe Sizlak | last post by:
Hi There, I am trying to return the value of a listbox control that is included as a user control, I can return the name of the control but I can't access the integer value of the selected item,...
6
by: Steve | last post by:
Hi, I open up a webform (vb.net) and populate a listbox control on the Page load event. If I click on (select) and item from the listbox I want to write the value of the selected item to a...
9
by: zdrakec | last post by:
Hello all: Clearly, I'm not getting it! Here is the scenario: On a web page, I have two list boxen and a text box. The first listbox is populated at page load time (if it is not a postback)....
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

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.