|
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..
|
|
|
|
|
This is my Dropdownlist. [ I assume you are binding it from Database.
<asp:DropDownList ID="DropDownList1" runat="server">
<asp:ListItem>us<asp:ListItem>
<asp:ListItem>india<asp:ListItem>
<asp:ListItem>koria<asp:ListItem>
<asp:ListItem>canada<asp:ListItem>
<asp:DropDownList>
[ I have removed / for formatting. ]
In page load I am using this,
protected void Page_Load(object sender, EventArgs e)
{
DropDownList1.SelectedValue = "india";
}
Here rather than india, you should use the value of user country.
|
|
|
|
|
thanks abhijith !!!
See my code one..
ddlCountry.SelectedValue = ds.Tables[0].Rows[0]["sCountry"].ToString();
am doing like this ?
in Selectedvalue showing null value.
try and try untill reach success..
|
|
|
|
|
Rajeshwar
First bind the ddlCountry with your country table data and
than use below mentioned code to select user's country.
ddlCountry.ClearSelection()
ddlCountry.Items.FindByText("user's country").Selected = True
Be an Eagle, Sky is Yours.
|
|
|
|
|
still there is no result..
try and try untill reach success..
|
|
|
|
|
When page loads, first Bind the Data with the dllCountry . Choose appropriate DataTextField and DataValueField .
Now after you finish your load using DataBind , use this.dllCountry.SelectedValue with the DataValueField you want.
Also please check if you have wrote
If(IsPostBack)return; in the Form_Load, so that when the page is posted back the selection remains.
|
|
|
|
|
Abhishek Sur wrote: Choose appropriate DataTextField and DataValueField.
I guess he is missing bind with DataValueField
|
|
|
|
|
yes... right.
If DataValueField is not specified, the value will be same as DataTextField . I personally always set ID as value so that I could set SelectedValue with some numeric field or GUID , as TextField may repeat.
|
|
|
|
|
thnks for all who reply me .. i tried like this also bu there is no output..
and this is my code
if (!IsPostBack)
{
DataSet ds1 = new DataSet();
ds1 = ad.dsGetvalues("Select * from Countries", true);
ddlCountry.DataSource = ds1;
ddlCountry.DataTextField = "sCountryName";
ddlCountry.DataValueField = "sno";
ddlCountry.Items.Insert(0, "--Select--");
ddlCountry.DataBind();
DataSet dss = new DataSet();
dss = ad.dsGetvalues("select * from UserDetails where PkiUsername ='"+Session["Username"].ToString()+"' ", true);
ddlCountry.SelectedValue = dss.Tables[0].Rows[0]["sCountry"].ToString();
}
try and try untill reach success..
|
|
|
|
|
Rajeshwar Code- Developer wrote: ddlCountry.DataValueField = "sno";
Try this
ddlCountry.DataTextField = "sCountryName";
ddlCountry.DataValueField = "sCountryName";
|
|
|
|
|
I'm using data access class that handles SQL requests and updates to db.
After I added delete, edit buttons in GridView, any clicks returns in error that the RowEditing, Deleting was not handled.
Also how can I update the GridView after I modified the selected row in DB? I use selection to edit that record in another page, and then update DB with custom DB class. How to alert GridView and its DataSet that the record now has different contents?
I tried to use ObjectDataSource for that purpose but it failed to launch reporting ambiguity between ~\bin web project module and the ASP.NET temporary one under windows folder
Чесноков
|
|
|
|