.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

Populating text box using SQL database.

Posted By:      Posted Date: April 14, 2011    Points: 0   Category :ASP.Net

So this seems like it should be easier than it has been for me.  I'm very new to ASP, so perhaps that's the reason.  I've searched the forum and found a couple previous postings that dealt with a similar issue to this, but I got nowhere fast with it. 

So here's what I've got.

I've created a website.  The user signs into that website, and they goto a Companies.aspx form.  Once in the companies.aspx, there are some fields where you can enter in a companie's name, number of clients with that company, and the company's website.  It's real simple so far. 

Once they finish that, they hit at a button called "Add Company"  This then adds a company to the sql database.   Just beneath this, I have a Gridview in which I display all of that user's companies that they have entered.

I've had no problem with getting any of this set up.  It's working great.  However, what I want to happen is to use the select function of the gridview to then re-populate the empty fields with the data that coresponds to the selected company in my gridview.  Then I will have an update button that will update that entery in my database.  I realize there is a quick edit function in the Gridview, but I dont like the way it looks. 

Now I've downloaded the employee info starter kit off of a

View Complete Post

More Related Resource Links

Update Profile Database from text file using BDC



I have a requirement to import the profile properties from a text file in sFTP to update the MOSS Profile Database. The objective is to create a single repository for the Staff Directory in MOSS.

Can I use BDC to connect and update the Profile database?

What is the alternate approach?


how to check the data which i passesd in text box for logine is available in the database or not.

Hi, I created login form in which ---Username, Password & LogOnType is there, When i m passing the correct value i m login successfully. But instead of entering correct value when i m entering wrong values and clicking SignIN its gives the exception. If i m not entering any value in text box and clicking SignIn its ask for values..................................... How i will make the validation which will check the textbox data which i entered there is correct or not. I want error  msg when data not in the database.........................if data in database then successfully logedIn msg.............   please help me ..............................try to give one example with code if possible   Thanku  

Why is it that this code updates my sql database with the default EditBox text?

Any help is appreciated. using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using System.Web.UI.HtmlControls; using MySql.Data.MySqlClient; public partial class _Default : System.Web.UI.Page { TextBox EditBox = new TextBox(); TableRow[] NewRows = { new TableRow(), new TableRow() }; TableCell[] NewCells = { new TableCell(), new TableCell() }; string ID; protected void Page_Init(object sender, EventArgs e) { } protected void Page_Load(object sender, EventArgs e) { var Connection = new MySqlConnection("Server=localhost;Database=site;Username=root;Password=root"); var Command = new MySqlCommand("select * from news", Connection); Connection.Open(); var Reader = Command.ExecuteReader(); while (Reader.Read()) { ID = Reader.GetString("ID"); string Title = Reader.GetString("Title"); string Text = Reader.GetString("Text"); foreach (TableRow Row in NewRows) { NewsTable.Rows.Add(Row); } NewCells[0].Text = Title; NewCells[1].Text = Text; NewCells[0].Font.Bold = true; NewCells[0].Font.Underline = true; NewCells[0].Font.Size = Fon

Only show text from database if field is not empty

 Hoping someone can help. I am using ASP.NET VB and i am wondering how to only show text from database if data exists. I tried this but it does not work.Any help would be greatly appreciated.I am new to .NET, in the past i have always used classic asp. 1 <td valign="top" style="border-right: 2px solid #031992"> 2 (<%# Eval("VenderPhone1") %>) <%# Eval("VenderPhone2") %>- <%#Eval("VenderPhone3")%> 3 4 <% If String.IsNullOrEmpty(Trim("VenderAlt1").ToString) Then%> 5 <br />(<%#Eval("VenderAlt1")%>) <%# Eval("VenderAlt2") %>- <%#Eval("VenderAlt3")%> 6 <% End If%> 7 <% If String.IsNullOrEmpty(Trim("VenderFax1").ToString) Then%> 8 <br />(<%# Eval("VenderFax1") %>) <%# Eval("VenderFax2") %>- <%#Eval("VenderFax3")%> 9 <% End If%> 10 11 </td> 12   

Populating DropDownList from Database

Hi there,I'm really struggling with this tonight (this being exactly what it says on the tin, (or the subject!)).  Code I'm working with right now is:If Not Page.IsPostBack Then Dim Category As String Dim CategoryReader As OdbcDataReader = Database.Read("SELECT * FROM tblBlogCategory") While CategoryReader.Read() Category = CategoryReader("Category").ToString() End While DropDownList1.DataSource = Category DropDownList1.DataBind() End IfI've also tried things likeDropDownList1.DataSource = Database.Read("SELECT * FROM tblBlogCategory") but it just stubbornly refuses to populate the list (i.e. the pagealways loads with a blank drop down list).  An idea I'm playing around with is putting the values of the Category table into an array, but it seems to have a problem with that as well.  Hope someone can advise me and point me in the right direction.  Feel free to be critical of my code too.ThanksDouglas

Need help with uploading a text file in to mysql database


I want to upload a text file and stored to my database. the column on my database it is longblob type. I don't know much about this so if anyone can help I will thank you. 

dynamically populating the database in the dropDownlist using c# in asp.net


hi everyone , plz listen my question very carefully

i have 2 tables  Desgn & EmpForm

Desgn table is lik this

CREATE TABLE [dbo].[Desgn](
    [DesignationCode] [int] IDENTITY(1,1) NOT NULL,
    [DesignationName] [varchar](50) NOT NULL,
    [DesignationCode] ASC

EmpForm table is like this

CREATE TABLE [dbo].[Empform](
    [EmpId] [varchar](50) NOT NULL,
    [EmpName] [varchar](50) NOT NULL,
    [EmpSalary] [numeric](18, 0) NULL,
    [EmpDesignationcode] [numeric](18, 0) NOT NULL,
    [EmpDateofBirth] [date] NOT NULL

now my ques is i want to dynamically populate the dropdown list of designation on the basis of the code but instead of code name should get populated .i have written the code like this 

public void Populate1()
        SqlConnection con = new SqlConnection(System.Configuration.ConfigurationSettings.AppSettings["co

Correct Way to Insert Data from Text Boxes on ASPX page into SQL Database Using VB


Please help me, I have been trying this for a week now and this is how far I have gotten.


I am new to this, and I am using MS Visual Web Developer Express.


OK - This is what I have come up with, but when I run it I get the following error  (I decided to just try to use a simplified table just to get an understanding of the basic concepts):



Partial Class label_form
    Inherits System.Web.UI.Page

    Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
        ' Declaring variables
        Dim username, labelname, ownersname, address1, address2, city, state, zipcode, country, contactnumber, emailaddress, data_source, con, sql_insert

        ' Check if Necessary Text Is Missing ( will do this once I can get it to work with no empty text boxes)

        ' Get Values from TextBoxes
        username = txtUserName.Text
        labelname = txtLabelName.Text
        ownersname = txtOwnersName

How to save WPF RichTextBox content (text + image) to the database



I want to save (and after that also to retrieve) the content of an WPF RichTextBox (text + image) to/from the database.

I found this: http://social.msdn.microsoft.com/Forums/en-US/wpf/thread/750a654e-b002-4742-8f46-609e93f6ec81 but like the author said, the solution seams not to work for text with image - the image is ignored/removed and only the formatted text is saved and after that retrieved to/from database.

Know someone a solution about this issue?

Best regards,





Populating a text box from a stored procedure value


Hi All,

I need to populate a text box from a stored porcedure call that does not have any parameters.  I've made the database connection and am executing the stored procedure, but I cannot figure out how to set a text box value to the return value of the stored procedure.  BTW, the stored procedure only returns one value.  Any help would be appreciated.



import text to database



I have a text file that looks like this:
Chapter 1
Line 1: some text here some text here
Line 2: some text here some text here
Line 3: some text here some text here

Chapter 2
Line 1: some text here some text here
Line 2: some text here some text here
Line 3: some text here some text here

I want to import this into a database so that the table will look something like this:
Chapter, Line, Text
1,1,some text here some text here
1,2,some text here some text here
1,3,some text here some text here
2,1,some text here some text here
2,2,some text here some text here
I guess I need to wrote some custom C#/VB code to get this done, is this correct or can I use SSIS with / without the custome code.


eddiec :-)

Search Text at database level.

How to search text value in the databse schema, it might be used in store procedures, views, tables and as an record within tables or views any where in database.

How to integrate SQL database and the text output from a C# program


Hi, I have been given a project saying that the server has to scan the files in a folder of client system and I should backup the files from the client if there are any new files. I have divided this project into modules:

1) client-server communication

2) filescanning and displaying the latest modified time of the files on console.

and what I intend to do is the list which is shown on the console right now should get embedded into the database so that the server can compare the files and check for the newer ones.

3) finally client sending the files to the server for backup.


I have accomplised till scanning of the files in a folder module. but I am not sure of doing the database part. Is there anyone to help in this kind of project.






sql database from text file

Hi, I am absolutely brand new to SQL and databases in general, but am trying to incorperate them into my projects.  My question is simple:  Is there a way to easily convert a text file to a sql database?  I've attempted to create a database through the Visual Studio IDE, but the problem is that I have far too many entries to enter the fields by hand (millions).  I have no need to modify the database at runtime yet or anything fancy, I just need to create this intial database from a text file, so I can learn how to do all the other things.

How to bind text containing HTML and ASP.NET tags from database



I have to show dynamic charts to clients.

I created table: ChartCodes

ChartCodeID     Code

1                      <asp:SqlDataSource ID='SqlDataSource_Chart1' runat='server' ConnectionString='<%$ ConnectionStrings:ConnectionString %>' SelectCommand='Usp_GetTotalEmissions_Org_chart' SelectCommandType='StoredProcedure'><SelectParameters>< . . .. . . . .

I wrote code of chart with sqldatasource in database column.

My problem is I could not able bind. I used DataList Control with a template and literal.

Bind literal with <%# Eval("Code") %>

But In sql I have ASP.NET tags <%  %>.   and when processing process %>, it assumes asp.net ends and wrote other text as it is in out put.

Please help me to find how to bind this text. Or any other Idea to display graphs from database as per user selection.

What are the best way to display text from database using MVC



I have created a MVC application its working fine. I have created a view which have few viewdata variables. I am filling these with my database values, and they are updated in loop. This method take 40-50 seconds to display actual page contents. So is there any other way to display the contents which we get till now and do refresh it till all contents are loaded.

Please let me know how can I refresh the page ?

Thanks in advance, Laxmilal Menaria

How to use auto complete in text box from database



I am using MS acess database 2007 and visula studio 2008.

i am workin on a windows application where i need to use the autocomplete functionality in text box and it should take values from the data base.

can anyone please help me with this?

thank you

ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend