Showing posts with label populate. Show all posts
Showing posts with label populate. Show all posts

Saturday, March 24, 2012

NEWBIE HELP

Hi All

I have a web form that uses an object class to populate a standard table (not datagrid etc)

I have a button on this form that when clicked opens another form for editing. In this form all the values of the object are used to populate text boxes (in the load event of the form there is a call to a DBHelper class which uses a SQL Parameter Array to execute a strored procedure (SQL) and return the data) and text areas which are free to edit in this form.

Also on this page I have a button called save changes which when clicked I am attempting to create a new paramater array to execute an update procedure again using the DBHelper Class.

Unfortunately when I try to do this the values in the new SQLParamater Array are exactly the same as before and are not reflecting the changes that I make by typing new entries into the text boxes on the form. As a newbie to .net I am lost here and realise that this is probably a scope or state problem but I would like someone to point me in the right direction please. When I hard wire the new SQLParamater Array the update does work so that eliminates the chances of the DBHelper Class from any fault.

Please help as I am going bonkers here!!!!!

Phill

You probably have your "populate form" bit in your Page Load function - which will execute when the save button causes a post back.

Surround your "populate the textboxes" code with:

if (!IsPostBack)
{

...

}

This will mean it only runs when the page is first loaded.


Have you looked if your sql update statement is passing the values as @.new_value

I would recommend doing this on a datagrid, it would be easier to update cuz the datagrid already has an update command field!


I cant use a datagrid as the recordset only ever returns one row with 17 fields. Datagrids need multirows to work dont they?


Datagrids work with "a number" of rows - that can be one row.


welshpunk:

I cant use a datagrid as the recordset only ever returns one row with 17 fields. Datagrids need multirows to work dont they?

Hi welshpunk,

Try to follow those codes as follows:

Working with a Single Table
http://msdn2.microsoft.com/en-us/library/aa719548(VS.71).aspx

Thanks.


Yes but you cannot turn a datagrid on its side. I have 17 fields in the recordset(just one row) Using a datagrid in this fashion is not user friendly as some of the fields are up to 2000 chars long. Datagrids will display like this

Column Heading Column Heading Column Heading Column Heading Column Heading

Data Data Data Data Data

I want to display the data in a more user friendly way like this

Column Header Data

Column Header Data

Column Header Data

Column Header Data

Column Header Data

Column Header Data

Column Header Data

With the 17 column headers on the left and their respective data adjacent to them. This is why I had to create the form in this way.


Hi,

You can write each cell every time by reading each cell once.

Hope this helps.


I have already marked as answer


Don't worry - you'll soon see that comment about marking posts as the answer absolutely everywhere!


You could try using a detailsview. The data would be displayed the way you want.

Newbie help.

I have a drop down box, and I want to populate a text box based on
what was selected on the drop down. The drop down contains an ID which
is the primary key for a table i'm using. The other column is the
description. So you select the id from the drop down and it populates
the text box with the appropriate description.
I'm new to ASP.NET and i'm using VB. I don't know how to do this. I
know there is an onChange method for the drop down, but then it sends
me to a spot to write some javascript. I know a little javascript, but
I don't know how to go from javascript to VB so I can query the
database again to get that description that has a the same ID as the
ListBox selected text.
Thanks in advance.
~Jeremywell if you dont have have the description in the client side you don't need
javscript unless you want to use AJAX
so you need a postback to the server
the simplest way
is to enable autopostback in the dropdown
and then catch the event onSelectedIndexChange of the dropdown (server
event) ( if your using vb double click on dropdown to add handler)
query the database and set the textbox text
hope it helps
<JeremyWoertink@.gmail.com> wrote in message
news:f2b0acf9-6d38-4f52-b5cc-247e89b29226@.e23g2000prf.googlegroups.com...
>I have a drop down box, and I want to populate a text box based on
> what was selected on the drop down. The drop down contains an ID which
> is the primary key for a table i'm using. The other column is the
> description. So you select the id from the drop down and it populates
> the text box with the appropriate description.
>
> I'm new to ASP.NET and i'm using VB. I don't know how to do this. I
> know there is an onChange method for the drop down, but then it sends
> me to a spot to write some javascript. I know a little javascript, but
> I don't know how to go from javascript to VB so I can query the
> database again to get that description that has a the same ID as the
> ListBox selected text.
> Thanks in advance.
>
> ~Jeremy
Do you really wanna do it on client side? because it is easy to do in on
server side.
1) check that you dropdownlst has runat="server" attribute
2) add onchange event handler in VS IDE in control properties.
3) set autopostback = true in control properties
right now if u put break point in your .cs onchange menthod it will be hit
each time u change values in drop down list
it means u can put any code there, like extract values from db and fill
other controls with the results
WBR, Michael Nemtsev [.NET/C# MVP].
Blog: http://spaces.live.com/laflour
"JeremyWoertink@.gmail.com" wrote:

> I have a drop down box, and I want to populate a text box based on
> what was selected on the drop down. The drop down contains an ID which
> is the primary key for a table i'm using. The other column is the
> description. So you select the id from the drop down and it populates
> the text box with the appropriate description.
>
> I'm new to ASP.NET and i'm using VB. I don't know how to do this. I
> know there is an onChange method for the drop down, but then it sends
> me to a spot to write some javascript. I know a little javascript, but
> I don't know how to go from javascript to VB so I can query the
> database again to get that description that has a the same ID as the
> ListBox selected text.
> Thanks in advance.
>
> ~Jeremy
>