|
sneha Choudhary wrote: <embed src="~/VISUALISE.SWF" style="HEIGHT: 331px; LEFT: 83px; TOP: 171px; WIDTH: 538px" />
will this work in my scenerio?
Yes - It should work for you, just change the source on each hyperlink click.
Coding C#
www.excitetemplate.com
|
|
|
|
|
i have a dropdown list i it has a different datafield(CouponName) and datavalue(CouponTypeID). i want that when i select a datafield it save datavalue in database so i make this code but it show error
input string was not in a correct format
protected void btnSubmit_Click(object sender, EventArgs e)
{
try
{
ErrorMessage.Text = "";
cnx.Open();
SqlCommand insertCmd = new SqlCommand("insert into CouponTransaction(CouponTypeID)values(@id)", cnx);
insertCmd.Parameters.Add("@Id", SqlDbType.TinyInt);
insertCmd.Parameters["@Id"].Value =Int32.Parse (ddlCType.SelectedValue);
insertCmd.ExecuteNonQuery();
ErrorMessage.Text = "Records inserted successfully";
cnx.Close();
}
catch (Exception ex)
{
ErrorMessage.Text = ex.Message;
}
|
|
|
|
|
Good day haleemasher
Change your code to
protected void btnSubmit_Click(object sender, EventArgs e)
{
try
{
ErrorMessage.Text = "";
cnx.Open();
SqlCommand insertCmd = new SqlCommand("insert into CouponTransaction(CouponTypeID)values(@id)", cnx);
insertCmd.Parameters.Add("@Id", SqlDbType.int);
insertCmd.Parameters["@Id"].Value = Convert.ToInt32(ToddlCType.SelectedValue);
insertCmd.ExecuteNonQuery();
ErrorMessage.Text = "Records inserted successfully";
cnx.Close();
}
catch (Exception ex)
{
ErrorMessage.Text = ex.Message;
}
You must put a break point and check what results you get from the selected value. it might have returned an empty string that is why you got that error. You must stop assuming the input from the user is correct.
Try it and tell me what it does
Vuyiswa Maseko,
Few companies that installed computers to reduce the employment of clerks have realized their expectations.... They now need more and more expensive clerks even though they call them "Developers" or "Programmers."
C#/VB.NET/ASP.NET/SQL7/2000/2005/2008
http://www.vuyiswamaseko.somee.com
vuyiswa@its.co.za
http://www.itsabacus.co.za/itsabacus/
modified on Friday, August 14, 2009 5:37 AM
|
|
|
|
|
when i change my code as u suggested it show error System.convert.Tonint32(object) is a method, which is not valid in the given context
the datatype of my ID is tinyint.
|
|
|
|
|
i have change the bold part , go to the thread and check again.
Vuyiswa Maseko,
Few companies that installed computers to reduce the employment of clerks have realized their expectations.... They now need more and more expensive clerks even though they call them "Developers" or "Programmers."
C#/VB.NET/ASP.NET/SQL7/2000/2005/2008
http://www.vuyiswamaseko.somee.com
vuyiswa@its.co.za
http://www.itsabacus.co.za/itsabacus/
|
|
|
|
|
|
Where is happening exactly. what line ?
Vuyiswa Maseko,
Few companies that installed computers to reduce the employment of clerks have realized their expectations.... They now need more and more expensive clerks even though they call them "Developers" or "Programmers."
C#/VB.NET/ASP.NET/SQL7/2000/2005/2008
http://www.vuyiswamaseko.somee.com
vuyiswa@its.co.za
http://www.itsabacus.co.za/itsabacus/
|
|
|
|
|
haleemasher wrote: input string was not in a correct format
in which line it shows this error
|
|
|
|
|
insertCmd.Parameters.Add("@Id", SqlDbType.Int );
it show error at this line
|
|
|
|
|
insertCmd.Parameters.Add("@Id", SqlDbType.Int );
insertCmd.Parameters["@Id"].Value =Int.Parse(ddlCType.SelectedValue);
if the error still occurs check the ID is integer or not....
|
|
|
|
|
my id datatype is tinyint
|
|
|
|
|
i dono whether i am correct but try to create a interger and parse your tineyint and assing it to the interger which you have crated, then pass the interger value as a parameter....
|
|
|
|
|
sorry not getting your point
|
|
|
|
|
insertCmd.Parameters.Add("@Id", SqlDbType.TinyInt); insertCmd.Parameters["@Id"].Value =Int32.Parse (ddlCType.SelectedValue);
instead of this...
insertCmd.Parameters.Add("@Id", SqlDbType.TinyInt);
int id = int.parse(ddlCType.SelectedValue);
insertCmd.Parameters["@Id"].Value =id;
|
|
|
|
|
|
Put a break point on the line with the error. What is the value of ddlCType.SelectedValue when the error occurs?
|
|
|
|
|
Check if what ever you are trying to convert to int is int actually.
Check if the value in SelectedValue is actually a integer.
Coding C#
www.excitetemplate.com
|
|
|
|
|
i want to bind a girdview with a formview so when i select data in gridview it show in form view and there i edit and insert data.
any link of article??
|
|
|
|
|
You cannot bind a gridview with a form view, because the form view is not a Data source. You can Bind a Grid and on selectedindexchange of the grid you bind the Form View based on the selection that is made.
Vuyiswa Maseko,
Few companies that installed computers to reduce the employment of clerks have realized their expectations.... They now need more and more expensive clerks even though they call them "Developers" or "Programmers."
C#/VB.NET/ASP.NET/SQL7/2000/2005/2008
http://www.vuyiswamaseko.somee.com
vuyiswa@its.co.za
http://www.itsabacus.co.za/itsabacus/
|
|
|
|
|
you can create a custom control for your requiremnt...
|
|
|
|
|
hi!!!!
i need to know ..
i have one dropdownlist called as ddlcountry. in this ddlcountry i m binding with table name called countries . i have one more table called userdetails .. already one user registered and selected his country frm ddl called USA .
so my doubt is i want to update his profile . when even user click his update page so i ll all from of him form db , here in ddlcountry .automatically show USA in ddlcoutry, do u know how to do it.
try and try untill reach success..
|
|
|
|
|
Rajeshwar Code- Developer wrote: so my doubt is i want to update his profile . when even user click his update page so i ll all from of him form db , here in ddlcountry .automatically show USA in ddlcoutry, do u know how to do it.
If you have the user information, its means you know the User Country. So set the Same to ddlCountry.
DropDownList1.SelectedValue = UserCountry;
Hope this will help
|
|
|
|
|
thanks for reply
i tried that .. seletedvalue showing null value..
try and try untill reach success..
|
|
|
|
|
Rajeshwar Code- Developer wrote: i tried that .. seletedvalue showing null value..
Why does you DropDown list does not have any data ? What are the value of those ?
|
|
|
|
|
here the thing is i was many countries binding to ddl frm countries table ..
so there is one more table called userdetails. for one user having one country right .. i want show automatically his country inj ddl.
try and try untill reach success..
|
|
|
|