Web Forms :: DropDownList Always Saving Default Value In Database?
May 7, 2015
dropdown list keep giving value -1 even i choose one of it already. tell me where i was doing wrong?
this is my code
<asp:DropDownList ID="ddl_viewer" runat="server">
</asp:DropDownList>
this is my vb code
Protected Sub LoadViewer()
ddl_viewer.DataSource = SQL_Viewer()
ddl_viewer.DataTextField = ("view_group")
ddl_viewer.DataValueField = ("view_ID")
ddl_viewer.DataBind()
ddl_viewer.Items.Insert(0, New ListItem("-- Choose --", "-1"))
[Code]......
this is my class
Dim sqlCmd As SqlCommand = New SqlCommand("Insert_News", ClsDBConn.GetDBConn)
sqlCmd.CommandType = Data.CommandType.StoredProcedure
Dim sqlParameter As SqlParameter
sqlCmd.Parameters.Add(New SqlParameter("RETURN_VALUE", SqlDbType.Int))
sqlCmd.Parameters("RETURN_VALUE").Direction = ParameterDirection.ReturnValue
[Code]......
and this is my stored procedure
ALTER PROCEDURE [dbo].[Insert_News]
-- Add the parameters for the stored procedure here
@News_Title VARCHAR (500),
@News_Viewer VARCHAR (500),
@News_Message VARCHAR (300),
@News_Author VARCHAR (100),
[Code]...
View 1 Replies
Similar Messages:
Jul 3, 2012
My dropdownlist is bind from database table. Now I want to add default item. How can I do that...
View 1 Replies
Aug 15, 2012
I have dropdown list in my page
BindDropDownList(DdlDistrict, "District1", "District", "ID");
DdlDistrict.Items.Insert(0, new ListItem("select district", "0"));
And I use this code for binding from database
DdlDistrict.Items.FindByText(_dr["District"].ToString()).Selected = true;
Here if in database have value it show in ddldistrict
Now I want if there wasn't any thing in database in dropdown list show "select district" that i define here
DdlDistrict.Items.Insert(0, new ListItem("select district", "0"));
View 1 Replies
May 7, 2015
I am using a viewstate to store the company Ids and splitting at hyphen.
protected void onCompanychange(object sender, EventArgs e) {
ViewState["companyID"] += companydropdown.SelectedValue + "-";
String companyids = ViewState["companyID"].ToString();
string pattern = "-";
company_array = Regex.Split(companyids, pattern);
company_length = company_array.Length;
}
Company array is a string array where i have stored the company ids
the problem is company_array[0] has the initial value of the dropdownlist(company) --select company which is why m getting the error(cannot convert data type nvarchar to int) . I have used the same logic in many places in my project it did not give any error.
int count = 0;
company_length = company_length - 1;
while (count < GridView3.Rows.Count && compid_counter < company_length ) {
cmd = new SqlCommand("insertWorkDetais", conn);
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.AddWithValue("@trainerId",trainerID);
[Code] .....
View 1 Replies
Jul 16, 2012
I bind dropdownlist in my page
protected void Page_Load(object sender, EventArgs e) {
BindDropDownList(DDL1, "city1", "name", "ID");
DDL1.Items.Insert(0, new ListItem("select city", "0"));
}
And SP
LTER procedure [dbo].[city1]
as
begin
select id,Name
from city
end
And design code
<asp:DropDownList ID="DDL2" runat="server" CssClass="daddsd">
</asp:DropDownList>
And here is imagebutton code that when click on it update data into table
protected void ImageButton_Click1(object sender, ImageClickEventArgs e) {
string data = Server.UrlDecode(Request.QueryString["BehCode2"]);
SqlCommand _cmd = new SqlCommand("insertinfo", _cn);
_cmd.CommandType = CommandType.StoredProcedure;
_cn.Open();
[Code] ....
Here when i click on button it insert all data into table but it didn't insert my selected item from dropdownlist it insert select city that i define in page_load
DDL1.Items.Insert(0, new ListItem("select city", "0"));
And when i delete this code from page load it insert in table first row of my table it didn't insert my selected item from dropdown list.
View 1 Replies
Jul 8, 2010
I have a windows application that stores a file on the current user's isolated storage, lets call this user Adam. On the same machine I have a Web service (The Web Service's application pool is running with Adam's credentials) that uses the same dll to access the file on the isolated storage but it is trying to access a file on the Default User's profile instead of the real user's profile (in this case Adams Profile)
Why is it trying to look for the file on the Default User's profile Instead of Adam's Profile? How can i make it look for the file in the right profile?. I'm running it on Win 2003, C# and .Net framework 3.5
View 1 Replies
Mar 26, 2012
I have two buttons ... one is insert btn another one is fileupload btn.
In the fileupload btn i creat a code in blow. I can upload the file successfully.
I need to insert a file in sql by using insert btn. For that I can create a insert query every thing but I cannot access the string filename value in the insert btn. So how I get the string value for insert btn. I mentioned the insert query also.
protected void UploadButton_Click(object sender, EventArgs e) {
string filePath = FileUploadControl.PostedFile.FileName;
string filename = Path.GetFileName(filePath);
string ext = Path.GetExtension(filename);
string contenttype = String.Empty;
[Code] ....
Insert Btn:
protected void btnInsert_Click(object sender, EventArgs e) {
cmd = new SqlCommand("insert into emp(FileName,ContanType, Data)values(@FileName, @ContanType, @Data)", con);
cmd.CommandType = CommandType.Text;
cmd.Parameters.AddWithValue("@FileName", filename);
cmd.Parameters.AddWithValue("@ContanType", contenttype); cmd.Parameters.AddWithValue("@Data",bytes);
con.Open(); cmd.ExecuteNonQuery();
con.Close(); Response.Redirect("Default.aspx");
} }
View 1 Replies
Jul 28, 2010
I am trying to set a default value for a dropdown from which i have an SQL datasource, heres my code:
<asp:DropDownList ID="DropDownList1" runat="server" DataSourceID="SqlDataSource1" DataTextField="name" DataValueField="name"></asp:DropDownList>
<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="..." SelectCommand="SELECT [title_id], [name] FROM [tbl_job_titles]"></asp:SqlDataSource>
I tried adding this:
<asp:ListItem Selected="True" Text="All" Value="All">All</asp:ListItem>
but it didnt work..
View 5 Replies
Jan 4, 2011
I have a fileupload control in my form which stores image to the SQL database as binary data.
BUT it stores as 0X000000.... I just realized that.
BUT IT DOESN'T MAKE ANY SENSE BECAUSE WHEN I PRINT THIS BYTE ARRAY IT SHOWS THE CONTENT.
This part is the server side code:
[Code]....
StoreToDatabase function:
[Code]....
DisplayFileContent function:
[Code]....
Displaying function shows like 2552162552240167470737001110960960025521906708667658777998101220131211111225181............BUT IN DATABASE it stores like 0X00000000000000000...
View 6 Replies
Jan 23, 2012
I am asking user to upload images using file upload control..In the database i am saving the filename as varchar. My problem is how do i save it.. If file name is saved in database where is file actually saved? If i make a folder to save,it is hard code path.. So, any way to save the file uploaded by user.
View 1 Replies
Feb 21, 2012
I am trying to make a photo gallery. I want to save the uploaded image to data base ...the article below at "
Display image after upload without page refresh or postback using ASP.Net AsyncFileUpload Control" shows how to show the uploaded image.. How to save the image in SQl Database?
I do not know how to do it.. Can the code be modified..?
View 1 Replies
Jun 1, 2010
I have a dropdownlist that is being populated using linq. The code for linq is below
[Code]....
When the page is viewed the dropdownlist show the following;towels, shoes, etc. What I would like is the default item to be nothing. That is when the page is viewed then the drop down list should show something like this "select category". Right now it is starting by showing towels, which is quite irritating, since if I want to see towels I first have to select something else and then go back and select it!
View 6 Replies
Jul 9, 2010
I have a dropdown list which I bind through a datasource. How can I inject a default value to it? My db doesn't have a default value and changes are not permitted!
View 6 Replies
Nov 23, 2010
I have a field that is a DropDownList. When in the insert mode I want that field to be blank - It currently is displaying the first record in the table it pulls from. I was expecting to see an initial value setting in the DropDownList properties but do not. For example - suppose I have a field named locations that consist of 4 location (below). In "Insert" mode, location currently displays Dallas. I want it to be set to blank initially and the user select one. What am I mssing?
View 4 Replies
May 3, 2012
I have dropdownlist i want in my DDL before selecting item show some text:
Like this
Please select city
View 1 Replies
Feb 17, 2011
I created a column named InputUserId for the purpose of saving the user's id upon inputing data using formview(so I know who inputed). I would like the user's id to be saved in the table (column InputUserId) and the table's Id (RId) to be saved in the user's profile.
View 8 Replies
Jul 27, 2012
I want to save my password and it sould be saved in encryptd form in my db SQl Server in asp.net.
View 1 Replies
Sep 20, 2015
After uploading image it appears somewhat like its upside getting down. I have getting some other suggestion for that is use ExifLib but I don't know how to get exif detail of image and fix image orientation property if it rotated automatically..!
View 1 Replies
Jan 11, 2011
I have a dropdownlist that is not bound to a datasource, I have hard coded a few items in the list cause the list is always constant and will never grow and there are only 4 entries init. Anyway, after i load the page and make a selection from the dropdownlist and do a postback, the dropdown always returns to the default selection...which tells the users to make a selection.How do I get the dropdown to keep the selected value after the postback? I want to be able to display the selected value all through until another selection is made.
View 6 Replies
Jul 4, 2012
I used the following link to add textboxes inside Gridview and saving data to Database.URL...The above article is very useful, but my problem is I want the Textboxes to be display in Rowwise instead of Columnwise. Means like I need to display is
Name texbox1
Age texbox2
Salary texbox3
SAVE ButtonThen SAVE button to save data entered in the textboxes to the database. Gridview design to achieve like this.
View 1 Replies
Apr 28, 2013
i used a file upload control to upload file..after uploading i want to preview image without storing its path or storing in DB or solution explorrer folder.when i upload using fileupload control..path of image comes in fileupload control now i used a button so,that on button click image should be displayed in image control..
View 1 Replies
Jan 11, 2010
what i have a is a dropdownlist and what i have done is set the datasource to be "select top 10 * from Orders"I have only displayed the OrderID , CustomerID and the Freight i would like to display in a dropdownlist. But what is happening is that for all 10 rows the dame value in the dropdownlist is shown. The dataset that is bound to the dropdownlist initially is all that items in the database.i would like the freight for that particualar Orderid to be displayed even if it is lets say item number 5 in the dropdownlist or itemn number 2 .
View 3 Replies
Oct 11, 2010
The intension is to get the all text file names in the drop down present in a particular location. When a user selects any filename from the drop down, it will show the data which is in that particular text file in a GridView.
I've done both the steps and it's almost complete but i stuck on a small issue. Probably because of non-usage of ASP.NET for a long period of time. The problem is, the drop down only selects the default value not other values.Here's my code for DropDown Selected Index Change
protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
{
DirectoryInfo di = new DirectoryInfo(@"C:myLogs");
[code]....
View 2 Replies
Dec 27, 2011
URL....If in the dropdownlist before making selection if i want to display like this -----Select a city------How can i do it?
View 1 Replies
Aug 6, 2010
I have gridview that has month as a column. When the user clicks a row's edit button, that row goes into edit mode. I have created a drop-down list for month in edit mode with the values 1-12. Right now, the drop-down list shows 1. I would like it to show the current value for that row. How do I do this? Here's the code for my gridview:
[Code]....
Here's some applicable code from the code behind:
[Code]....
View 4 Replies