|
I am trying to get a datagrid to update. Everything else
in it works. However when I try to retrieve the new value
it passes me the original value. Any Ideas? Thanks.
public void UpdateGrid(object sender, DataGridCommandEventArgs e)
{
UpdateVendor.Connection = Global.sqlConnection;
UpdateVendor.Parameters[0].Value = dgVendors.DataKeys[(int)e.Item.ItemIndex];
UpdateVendor.Parameters[1].Value = ((TextBox)e.Item.Cells[3].Controls[0]).Text;
UpdateVendor.Parameters[2].Value = ((TextBox)e.Item.Cells[4].Controls[0]).Text;
UpdateVendor.Parameters[3].Value = ((TextBox)e.Item.Cells[5].Controls[0]).Text;
UpdateVendor.Parameters[4].Value = ((TextBox)e.Item.Cells[6].Controls[0]).Text;
UpdateVendor.ExecuteNonQuery();
dgVendors.EditItemIndex = -1;
dgVendors.DataBind();
Response.Redirect("ManageVendors.aspx");
}
Steve
Not all who wander are lost...
|
|
|
|
|
Still can't get it? Did you read the article?
|
|
|
|
|
I read your article several times. Do I have explicitly have all the items be textboxs? Do I have to process the Textboxs OnTextChanged message even if I just want the end result? If the arguements passed are the original values what use is the update command? Thanks.
Steve
Not all who wander are lost...
|
|
|
|
|
a couple of points...
1. you are using a global sqlconnection....this could hog resources...i'd at least try to close it after every use and reopen it before every use...the datagrid is good at displaying disconnected data (that's that the System.Data.DataSet object is)
2. make sure you aren't calling DataBind() in your page_load event every time, or else it'll grab the data right from sql again
should be something like
public void page_load()
{
if (!Page.IsPostBack)
{
Page.DataBind();
}
else
{
//do nothing...page was posted back, and data will remain in datagrid unless changed in another function
}
}
hope this helps
michael griffith
--------------------
mgriffith@lauren.com
mdg12@po.cwru.edu
|
|
|
|
|
Here is what I am doing to create an sql statement to query my database and return records displaying them as a bulleted list:
1.<%
2.Set catRS = Server.CreateObject( "ADODB.Recordset" )
3.catRS.ActiveConnection = Con
4.sqlString = "SELECT DISTINCT product_category FROM Products "
5.sqlString = sqlString & "WHERE product_status=1 "
6.sqlString = sqlString & "ORDER BY product_category "
7.catRS.Open sqlString
8.%>
9.<% If cat = "Home" THEN %>
10.Home
11.
12.<% ELSE %>
13.Home
14.<% END IF %>
15.<% WHILE NOT catRS.EOF %>
16.<% IF catRS( "product_category" ) = cat THEN %>
17.
18.<%=catRS( "product_category" )%>
19.
20.<% ELSE %>
21.- "><%=catRS( "product_category" )%>
23.<% END IF %>
24.<%
25.catRS.MoveNext
26.WEND
27.%>
28.
29.<% catRS.Close %>
And I receive this error message when trying to open up the default.asp page that includes this catlist.asp file to populate a menu:
Error Type:
Microsoft OLE DB Provider for ODBC Drivers (0x80040E0C)
Command text was not set for the command object.
/cham2DSN/catlist.asp, line 7
Can anyone give me any clues???
|
|
|
|
|
You might want to try that again, and check the "display as-is" box
--
Help me! I'm turning into a grapefruit!
|
|
|
|
|
Ok, here is my go at it, it does appear to be a little jumbing as ben said before.
Do something like this:
<%
Dim conn
Dim catRS
Dim sql
With Response
Set conn = Server.CreateObject("ADODB.Connection")
Set catRS = Server.CreateObject("ADODB.Recordset")
sql = "SELECT DISTINCT product_category FROM Products " & _
"WHERE product_status=1 ORDER BY product_category"
conn.ConnectionString = <code>[YourConnectionStringGoesHere]</code>
conn.Open
catRS.ActiveConnection = conn
catRS.Open sql
If Not catRS.EOF Then
.Write "<ul>" & vbcrlf
Do Until catRS.EOF
If catRS("product_category") = <code>"SomeWord"</code> or <code>Variable</code> Then
.Write "<li>" & catRS("product_category") & "</li>"
End If
catRS.MoveNext
Loop
.Write "</ul>"
End If
catRS.Close
set catRS = nothing
conn.Close
set conn = nothing
End With
%>
HTH
Nick Parker
|
|
|
|
|
3.catRS.ActiveConnection = Con
Where do your "Con" come from?
|
|
|
|
|
I am wondering how (if it is possible) to do the following:
You have a login form with a login ID (email address) and a password. When the user clicks the "Submit" button, go to a page that varifies the email address and password. That part I've got done -- easy.
What I would like is to have another button, or a link, that will go to a different page that will send the user their password in an email. So what I'm wondering is how can this other page (the one sending the email) get the email address the user entered on the form? I would rather not simply redirect them to a second page where they enter the email address. If possible, I would like to be able to read the email address entered on the login form. Can it be done? If so, how?
My understanding is that the data on the form is not available to subsequent pages until the form is submitted (which activates the "action" page, right?). Is there a way around that, or am I missing something basic?
Thanks.
|
|
|
|
|
<form action="original.html" method="post">
<input type="text" name="email">
<input type="password" name="passwd">
<input type="submit" value="OK">
<input type="button" value="Forgot Passowrd" onClick="this.form.action='newpage.html';this.form.submit();">
</form>
Jeremy Falcon
Imputek
<nobr>"..." - Paul Watson 07-17
|
|
|
|
|
It works like a charm.
That's excellent. Thanks.
|
|
|
|
|
David Fleming wrote:
I would rather not simply redirect them to a second page where they enter the email address. If possible, I would like to be able to read the email address entered on the login form. Can it be done? If so, how?
Jeremy's way works well, but an alternative (always good to have options) is to have the FORM still go to the same handling ASP page, but also have a hidden text box in the FORM which tracks which button was clicked.
Then in the ASP you can check which one was clicked and do whatever is appropriate.
The benefit is that you can save some coding by having only one ASP page and not two. The down side is there is a bit more code (HTML and JavaScript) on the originating FORM page.
If you need some help with the hidden text box method just ask...
regards,
Paul Watson
Bluegrass
Cape Town, South Africa
The greatest thing you'll ever learn is just to love, and to be loved in return - Moulin Rouge
Alison Pentland wrote:
I now have an image of you in front of the mirror in the morning, wearing your knickers, socks and shoes trying to decided if they match!
|
|
|
|
|
Ah, good idea.
I've already coded it the other way, but thanks for the alternative. I agree, always good to have alternatives.
I've used hidden text boxes but didn't even think of that.
|
|
|
|
|
|
In theory, very similar to the first reply I got, in that you change the ".action" to the new page. But very slick. I also liked the idea one person, who wrote a message on the article's page, had about having a single function that takes a parameter that tells it which page to redirect to. Very nifty.
Thanks everyone.
|
|
|
|
|
Yes - the guy "Mr Picky" is a mate of mine who wrote just to let me know that my code was messy and unweildy (What are friends for, eh? )
cheers,
Chris Maunder
|
|
|
|
|
i need to detect carrige resturns, and replace them with < b r >, thet text will of couse be entered into a text area in a form.
the technolodies i have at my disposal, are Javasciprt and PHP, does anyone know if this is possible?
Email: theeclypse@hotmail.com URL: http://www.onyeyiri.co.uk "All programmers are playwrights and all computers are lousy actors."
|
|
|
|
|
never mind people, i found a function in PHP, the nl2br() function.
to use it, simply do
nl2br("this\nstring\nhas\nreturns");
and it turns the \n into <br>
Email: theeclypse@hotmail.com URL: http://www.onyeyiri.co.uk "All programmers are playwrights and all computers are lousy actors."
|
|
|
|
|
Nnamdi Onyeyiri wrote:
and it turns the \n into <br>
Just an FYI...
\r\n = Windows (not in textareas, but in text files)
\n = Unix\Linux\Posix, etc.
\r = Macintosh
Jeremy Falcon
Imputek
<nobr>"..." - Paul Watson 07-17
|
|
|
|
|
|
This information really depends on what you are doing, but I first came across this issue when developing a website on a PC using PHP for a client using mainly Macs.
I was using my own API; however, and not nl2br() because it didn't provide enough functionality. I'm not sure if nl2br() will handle carriage returns and line feeds instead of just line feeds. I'll have to check I guess.
Jeremy Falcon
Imputek
<nobr>"..." - Paul Watson 07-17
|
|
|
|
|
whats the difference? it works with the text like this
bla\nbla\nbla
and it also worked when i made a text file in notepad, uploaded it, then use a php script to open it, parse it with the nl2br() function.
Email: theeclypse@hotmail.com URL: http://www.onyeyiri.co.uk "All programmers are playwrights and all computers are lousy actors."
|
|
|
|
|
Nnamdi Onyeyiri wrote:
and it also worked when i made a text file in notepad, uploaded it, then use a php script to open it, parse it with the nl2br() function.
You're not using a Mac. The data in a textarea is processed on the client by the browser and sent to the server. Just searching for \n will also catch \r\n, but not \r by itself.
Jeremy Falcon
Imputek
<nobr>"..." - Paul Watson 07-17
|
|
|
|
|
Hi:
I am right now developing an application that involves filing up a pretty big report which spans over 5 pages.Now Right now the application has been so designed that everytime a page is filled up the connection to the database is opened,data is updated and then its closed.
But then now slowly security is starting to worry us and i am not too happy about having my connection string out for grabs in all pages..
Can You Suggest some articles or information that will help me with the design of applications taking security point of view..
People suggest using COM Objects for each page to help me in updating data.
Why Need Parking lots in Bars when Drunken Driving is Prohibited
|
|
|
|
|
Just a couple hours ago I started writting my own forums front end and have pretty much finished and now it is time to move on to the database backend.
What kinda structure would best be suited for a forum like this one...???
I'm thinking
Table: Forum
[PKID][Date][Email][Username][Password][Subject][Content]
the one feature I admire the most about CP is the nested child nodes...something that really lacks in other message forums around the net...and something i've taken care of in my own...
Anyways...if anyone has any tips about the database backend of things please lemme know...like do I create a new table for each message thats started...??? Or should I keep all messages inside the one table and use fancier code to track which message get inserted where...???
Thanx
Cheers!
p.s-pardon me for sounding unclear, but I haven't slept for quite a while and it's starting to catch up with me...
"An expert is someone who has made all the mistakes in his or her field" - Niels Bohr
|
|
|
|