Thursday, March 22, 2012

ListBox AutoPostBack Error

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
resolved!

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
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)
ias0nas@.freemail.gr

Thank you

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

0 comments:

Post a Comment