Web Forms :: Can Load A Ddl With Content From A Database
Dec 6, 2010
I have a database table a field that is the 5 character cultureinfo code. I would like to create a dropdown control that has its value set from the database field (the database table contains only a list of those languages supported by the site) but displays the cultureinfo name.
i have encountered a problem on how to load the database images to be display in the Image content in the web pages. I am currently using an Access database with a table "Images" and there are 4 columns in it. "ImageID", "ImageDescription","ImageofPicture","Description". Below is my code: Words highlighted in bold is where the problem occurs. No image is display in the Image box but theres a red cross at the top left. Image description is displaying fine in the textboxes
int MaxRows = 0; int inc = 0; int inc1 = 1; int inc2 = 2; int inc3 = 3; System.Data.OleDb.OleDbConnection cs; System.Data.OleDb.OleDbDataAdapter dta; DataSet ds1; byte[] photo_array; protected void Page_Load(object sender, EventArgs e) { cs = new System.Data.OleDb.OleDbConnection(); //tell the program where the database is located cs.ConnectionString = "Provider=Microsoft.Jet.OleDb.4.0;Data Source=C:\Users\Admin\Desktop\Website1\App_Data\Database.mdb"; ds1 = new DataSet(); string sql = "SELECT * From Images ORDER BY ImageDescription ASC"; dta = new System.Data.OleDb.OleDbDataAdapter(sql, cs); cs.Open(); dta.Fill(ds1, "Images"); Navigation(); //MaxRows equals to the total amount of records from the database MaxRows = ds1.Tables["Images"].Rows.Count; } private void Navigation() { //get the first records from the database DataRow dtaRow = ds1.Tables["Images"].Rows[inc]; //get column values in the row TextBox3.Text = dtaRow.ItemArray.GetValue(1).ToString(); TextBox7.Text = dtaRow.ItemArray.GetValue(3).ToString(); DataRow dtaRow1 = ds1.Tables["Images"].Rows[inc1]; TextBox4.Text = dtaRow1.ItemArray.GetValue(1).ToString(); TextBox2.Text = dtaRow1.ItemArray.GetValue(3).ToString(); DataRow dtaRow2 = ds1.Tables["Images"].Rows[inc2]; TextBox5.Text = dtaRow2.ItemArray.GetValue(1).ToString(); TextBox8.Text = dtaRow2.ItemArray.GetValue(3).ToString(); DataRow dtaRow3 = ds1.Tables["Images"].Rows[inc3]; TextBox6.Text = dtaRow3.ItemArray.GetValue(1).ToString(); TextBox9.Text = dtaRow3.ItemArray.GetValue(3).ToString(); //if 3rd column value is not null if (ds1.Tables[0].Rows[inc][2] != System.DBNull.Value) { Image5.ImageUrl = "ImageHandler.ashx?ImageDescription=" + TextBox3.Text; } if (ds1.Tables[0].Rows[inc1][2] != System.DBNull.Value) { Image5.ImageUrl = "ImageHandler.ashx?ImageDescription=" + TextBox4.Text; } if (ds1.Tables[0].Rows[inc2][2] != System.DBNull.Value) { Image5.ImageUrl = "ImageHandler.ashx?ImageDescription=" + TextBox5.Text; } if (ds1.Tables[0].Rows[inc3][2] != System.DBNull.Value) { Image5.ImageUrl = "ImageHandler.ashx?ImageDescription=" + TextBox6.Text; } } } Code for ImageHandler.ashx: using System; using System.Web; using System.Data.OleDb; public class ImageHandler : IHttpHandler { public void ProcessRequest (HttpContext context) { string qry = "SELECT ImageofPicture FROM Images WHERE ImageDescription = ?"; string connect = "Provider=Microsoft.Jet.OleDb.4.0;Data Source=C:\Users\Admin\Desktop\Website1\App_Data\Database.mdb"; using (OleDbConnection conn = new OleDbConnection(connect)) { if (context.Request.QueryString["id"] != null) { OleDbCommand cmd = new OleDbCommand(qry, conn); cmd.Parameters.AddWithValue("", context.Request.QueryString["id"]); conn.Open(); using (OleDbDataReader rdr = cmd.ExecuteReader()) { if (rdr.HasRows) { rdr.Read(); context.Response.ContentType = "image/jpeg"; context.Response.BinaryWrite((byte[])rdr["ImageofPicture"]); } } } } } public bool IsReusable { get { return false; }
I'm using this Ajax script [URL] to load content from an aspx page on another server than the page calling the content. So far I've learned that this is a no go. The problem seems to be that when using an absolute link to content the script fails as apposed to using a relative link.
I've searched the web for about 10 hours now, and I still haven't found what I'm looking for.
I create a website with enable default content page. the default content is login page index.aspx. During testing, I found one interesting issue. If I type the URL in browser without specify the page, the site is working fine.
[URL]
If I change the url with specify the default entry page, index.aspx, the login page is working correctly. The problem is, in navigate to another page, I can see one Get index.aspx request send back to server. I don't see this 200 request in the previous test. Why? is that anything wrong?
I want the AdRotator control functionality where content pages on page load but instead of using images I want to use html and other controls like textboxes and buttons. Is this possible?
Everything works absolutly fine in dev, but when I move the solution to IIS 7, I get this error! CompanyWeb is the masterpage, which is located in the login directory. Here is the page directive for login.aspx, which is the offending page
am new in asp.net and i started to build a social network web page.i want to have only one profile page,but load diferrent content on it for each user, and have an id for each user profile page something like "mypage.com/profile.aspx?id=234234234".i have no idea of how to do that.i hope that you understand what i want.
I want to implement it with ajax in the following way:
when user click out side of iframe dont postback page and change the src of iframe .I want to show the progress inside the progressupdatepanel
I mention it I dont want to run any postback just loading page inside the iframe with ajax by calling outside of iframe for example there is a button in the page and it is handled by update panel and it loads the content of other page inside the iframe.
I have the following placeholder in my main master page. I would like to not have to duplicate my news content in several content pages, so I choose to simply not provide this content in them, and the master page should provide its default.
When I try the following code, I get an error because newsGrid is null. I assume I'm doing this at the wrong place in the page lifecycle, but I don't know where the right place is.
For some reason I cannot get my content page to load google map. Here is my code in the page load of my content page:-
Code: If Not IsPostBack Then ClientScript.RegisterStartupScript(Page.ClientScript.GetType, "loadmap", "loadgooglemap();", True) End If
I have my javascript in a file called googlemap.js which holds this:-
// JScript File
Code: function setgooglekey() { var headID = document.getElementsByTagName("head")[0]; var script = document.createElement('script'); var referrerUrl = document.location;
I would to know how can it be achieved by loading page content into a specific DIV without entirely refreshing a page. I mean if I click on linkbutton or a normal link on my menu bar like Contact us, the conact us content is loaded into the DIV and the same if another link is clicked on the menu Bar.
I want to call a javascript method during page load. I am using application.master of the sharepoint server 2007 as the master page . In the content page i want to call a custom method named OnLoadFun() during loading the content page. I have written the function inside script tag in the PlaceHolderAdditionalPageHead id section of the content page.
[Code]....
How do i call the OnLoadFun method so the i is being called onload time. i tried putting window.onload=OnLoadFun surrounded by script tag within the PlaceHolderMain content section.
I am writing an Administration Module which it lets the administrator to Add/Delete the items in TreeView. I know that I have to store the Items in SQL Database but I dont know how to retrieve them and bind to the TreeView and then Link them to related pages.
I have found some Tutorials but I did not understand completly. I've seen that they used to have the www.testwebsite.com/PageID=1?
insert data to database from a content page of a master page. My code is working fine when i use my code without master page but with content page of master page i dnt knw what goes wrong.
I am embedding a popup extender inside a tab...simple enough - for some reason the content is visible when the page loads - it can be dismissed by selecting the button and then dismissing the popup. Everything works in compatability mode.
I can't tag the panel as visible=false as it is no longer rendered at all.
i have a web application with sql server 2008 i wanna know if its possible to load the data automatically after its been inserted to DB..i have a alerts table which store message and user name to which the alert is to be send i wanna display the alert msg to user after it has been inserted...
i am using MSSQL Server 2005 with VB in my codebehind. I have an application that I have written as a time tracking system that uses SQL Membership provider to secure the site with forms authentication. I want to add additional functionality to the site. My company has a intranet SharePoint site. I want to add something on the front page of the SharePoint site that will allow the users to clock-in/out without having to login to the application. I have a users table that is not part of the SQL Membership Provider that holds detailed information about the employees. There is a column in that table that identifies users as being able to use the clock-in system. I want to be able to display a clock-in/out button on the paged based on that column. Not all users have the ability to clock-in as their time does not need to be tracked.
I have been looking for the last day since some who was nice enough to suggest I change the look of my web application theme by haveing different css sheets. I have found many references to
where stylesheet_name is a value from a database entery
The css file has loaded into the app fine and I know the value of stylesheet_name does return what I want because I sent it to a label control and the file name comes up.
I am working on the application that allows user to upload a file (from their local machine) and store the uploaded file in database.Then,the content of the file (such as ContentType,FileSize etc)can be view in a DetailsView control.
How can i load the QuoteNumber database column values into dropdown list which is autogenerated column.I am able to generate the QuoteNumber value and same inserting into database simultaniously all the Quotenumber values should load into dropdown, these two should happen in one click button event.My QuoteNumber dropdown name is "DDQuote" Code for generating Quotenumer and same inserting into database.
Protected Sub btnAQ_Click(ByVal sender As Object, ByVal e As EventArgs) Handles btnAQ.Click Console.WriteLine(updateRecord("insert into quotes (PartNumber) values ('" + txtPart.Text + "')")) retriveDataToDataGrid() End Sub Function updateRecord(ByVal query As String) As Integer Try Dim connectionString As String = "Database=fabdb;" & "Data Source=localhost;" & "User Id=root;Password=pacvision" Dim rowsEffected As Integer = 0 Dim connection As New MySqlConnection(connectionString) Dim cmd As New MySqlCommand(query, connection) connection.Open() rowsEffected = cmd.ExecuteNonQuery() connection.Close() Return rowsEffected Catch ex As Exception Console.WriteLine(ex.Message) End Try End Function
I am using C# and VS 2008 with access database. I have a nested gridview (2) with two access database tables. Date1 (takes System date) is the primary key in table1 and also present in table2 as foreign key. User data is stored in gridview 2 w.r.t to the date in gridview1. What i am tryin to do is to mail todays date (System date) data of Gridview 1 and data corresponding to it in Gridview 2 to a specific mail id.