i trying select user default_information.aspx.cs
page , display user information on registration.aspx
page created registration form.
i getting system.nullreferenceexception:object reference not set instance of object
error. please me. i've given main part of it. debugged it. found every data selected db in string strusername
,strpassword
. code breaks on usernametxt.text = strusername;
when try show username or password on text field.
default_information contains
protected void gridviewprofile_selectedindexchanged(object sender, eventargs e) { registration objdef = new registration(); string username = gridviewprofile.rows[gridviewprofile.selectedindex].cells[1].text; objdef.displayuser(username); } protected void update_click(object sender, eventargs e) { response.redirect("registration.aspx"); }
registration.aspx contains
protected void register_click(object sender, eventargs e) { user objuser = new user(); objuser.username = usernametxt.text; objuser.password = passwordtxt.text; objuser.email = emailtxt.text; objuser.save(); } public void displayuser(string username) { user obj = new user(); dataset objdataset = obj.profile(username); string strusername = objdataset.tables[0].rows[0][0].tostring(); string strpassword = objdataset.tables[0].rows[0][1].tostring(); string stremail = objdataset.tables[0].rows[0][2].tostring(); usernametxt.text = strusername; passwordtxt.text = strpassword; emailtxt.text = stremail; }
user class contains
public class user { public void save() { clssqlserver obj = new clssqlserver(); obj.insertuser_info(username,password,email); } public dataset profile(string username) { clssqlserver obj = new clssqlserver(); return obj.getalluser_info(username); } }
clssqlserver contains
public dataset getalluser_info(string username) { string connectionstring = "data source=localhost\\mssql;initial catalog=blooddb;integrated security=true"; sqlconnection objconnection = new sqlconnection(connectionstring); objconnection.open(); string command = "select * login_donor username='" + username + "' "; sqlcommand objcommand = new sqlcommand(command, objconnection); dataset objdataset = new dataset(); sqldataadapter objadapter = new sqldataadapter(objcommand); objadapter.fill(objdataset); objconnection.close(); return objdataset; } public bool insertuser_info(string username,string password,string email) { string connectionstring = "data source=localhost\\mssql;initial catalog=blooddb;integrated security=true"; sqlconnection objconnection = new sqlconnection(connectionstring); objconnection.open(); string strinsertcommand = "insert login_donor values('"+ username +"','"+ password + "','"+email+"')"; sqlcommand objcommand = new sqlcommand(strinsertcommand, objconnection); objcommand.executenonquery(); objconnection.close(); return true; }
it looks using asp.net create user wizard control.because controls buried inside container, have rewarded after little excavation..lets start digging......
using wizard accessible locate text box
textbox usernametxt= (textbox)createuserwizard.findcontrol("usernametxt"); usernametxt.text = strusername;
hope help.
Comments
Post a Comment