|
Actually the test case I am trying is a single ASPX file. It works if I pull the data to the server as opposed to puching it from my development box. Unfortunately I wouln't always have that luxury if I need to push to a third party host.
|
|
|
|
|
I have a datagrid with a lot of columns that I need to creat a sql update statement from. Most of the examples do something like the following:
TextBox hours = (TextBox)objArgs.Item.FindControl("hours");
TextBox days = (TextBox)objArgs.Item.FindControl("days");
TextBox userid = (TextBox)objArgs.Item.FindControl("userid");
.... repeat for all controls in the grid
string sql = "update userinfo set hours = " + hours.Text + ", days = " + days.Text + " where userid = " + userid.Text;
As you can imagine this take a lot of code for a table with a lot of columns.
Is there a way to enumerate the bound columns of a datagrid? Something like:
string sql = "update userinfo set ";
foreach (BoundColumn column in myDataGrid)
{
sql += column.Name + " = " + column.Text ", ";
}
would be really nice.
Todd Smith
|
|
|
|
|
I believe you need to do it this way.
private void OnUpdate(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e)
{
TextBox text = (TextBox)e.Item.FindControl("Edit1");
Label label = (Label)e.Item.FindControl("Label1");
}
|
|
|
|
|
Hi all,
I have one iframe element on my aspx page. I want to pass the content of the
iframe back to the
codebehind file for saving to the database. Is there any way to grab this
information and post back?
Peter Marino
IO Interactive
|
|
|
|
|
Like subject says... I have problems when including a file more than once,
so having something like a #define would avoid including a file twice.
I'd also like to use that for creating a language file, so to translate my
website, I'd only have to modify that file...
Thanks!
I just found out that Const would do that for me, but now I need an equivalent to #ifdef, #else and #endif...
---------------
http://www.edovia.com
|
|
|
|
|
Hi All,
I am using ASP.NET and C#
I would presume this is an easy question but I can't seem to find any information about it.
I would like to add a button to my webpage that when clicked acts just like the print option of Internet Explorer. ie. Brings up a box to ask you what printer you want to print.
I'm sure there must be a straight function that I can call, something like Document.Print?
Thanks,
Gavin
|
|
|
|
|
code example:
<SCRIPT Language="Javascript">
function printit(){
if (window.print) {
window.print() ;
} else {
var WebBrowser = '<OBJECT ID="WebBrowser1" WIDTH=0 HEIGHT=0 CLASSID="CLSID:8856F961-340A-11D0-A96B-00C04FD705A2"></OBJECT>';
document.body.insertAdjacentHTML('beforeEnd', WebBrowser);
WebBrowser1.ExecWB(6, 2);
}
}
</script>
<SCRIPT Language="Javascript">
var NS = (navigator.appName == "Netscape");
var VERSION = parseInt(navigator.appVersion);
if (VERSION > 3) {
document.write('<form><input type=button value="Print this Page" name="Print" onClick="printit()"></form>');
}
</script>
source: http://www.dynamicdrive.com/dynamicindex9/other1.htm
|
|
|
|
|
Thanks a million,
Works like a treat
|
|
|
|
|
I was wondering if anyone knew if connection pooling will work with an as/400 backend?
Thanks
|
|
|
|
|
What are your favorite ASP.NET sites for learning more complex stuff?
Todd Smith
|
|
|
|
|
Start with www.asp.net? It is a Microsoft maintained site
|
|
|
|
|
There are many web hosting provider, but they don't support ASP ?.If you know any please tell me.
Thank you very much.
|
|
|
|
|
My "preferred" Hosting provider for ASP.NET is WebStrikeSolution.com! They offer a nice package for ASP.NET and the price is hard to beat! Check it out: http://www.webstrikesolutions.com/windows.html
I had been using the Web Hosting provided by my ISP (included with the service, however, the ISP Tech's just weren't up-to-speed with ASP.NET and I don't want to have to teach them as well as myself. So, I chose to switch and have been happy so far!
Regards,
KoalaCowboy
Knowledge Monster Extraordinaire
|
|
|
|
|
|
Hello;
I have trouble with SQL Server 7.0 API. I'm getting following error at link phase. Source code at below; (VC++ 6)
// SmcDatabase.cpp: implementation of the CSmcDatabase class.
//
//////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "smc_client.h"
#include "SmcDatabase.h"
#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif
#define MAXBUFLEN 255
#include <stdio.h>
#include <string.h>
#include <windows.h>
#include <sql.h>
#include <sqlext.h>
#include <odbcss.h>
#include <afxpriv.h>
#include <afxdisp.h>
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
CSmcDatabase::CSmcDatabase()
{
}
CSmcDatabase::~CSmcDatabase()
{
}
HRESULT CSmcDatabase::Connect(char* server, char* uid, char* pwd)
{
SQLHENV henv = SQL_NULL_HENV;
SQLHDBC hdbc1 = SQL_NULL_HDBC;
RETCODE retcode = 0;
// This format of the SAVEFILE keyword saves a successful
// connection as the file Myfiledsn.dsn in the ODBC default
// directory for file DSNs.
SQLCHAR szConnStrIn[MAXBUFLEN] =
"SAVEFILE=MyFileDSN;DRIVER={SQL Server};SERVER=MySQL;"
"NETWORK=dbmssocn;UID=sa;PWD=MyPassWord;";
SQLCHAR szConnStrOut[MAXBUFLEN];
SQLSMALLINT cbConnStrOut = 0;
// Allocate the ODBC Environment and save handle.
retcode = SQLAllocHandle (SQL_HANDLE_ENV, NULL, &henv);
// Let ODBC know this is an ODBC 3.0 application.
retcode = SQLSetEnvAttr(henv, SQL_ATTR_ODBC_VERSION,
(SQLPOINTER) SQL_OV_ODBC3, SQL_IS_INTEGER);
// Allocate an ODBC connection handle and connect.
retcode = SQLAllocHandle(SQL_HANDLE_DBC, henv, &hdbc1);
retcode = SQLDriverConnect(hdbc1, // Connection handle
NULL, // Window handle
szConnStrIn, // Input connect string
SQL_NTS, // Null-terminated string
szConnStrOut, // Addr of output buffer
MAXBUFLEN, // Size of output buffer
&cbConnStrOut, // Address of output length
SQL_DRIVER_NOPROMPT);
return(retcode);
}
Error message;
--------------------Configuration: smc_client - Win32 Debug--------------------
Linking...
SmcDatabase.obj : error LNK2001: unresolved external symbol _SQLDriverConnect@32
SmcDatabase.obj : error LNK2001: unresolved external symbol _SQLSetEnvAttr@16
SmcDatabase.obj : error LNK2001: unresolved external symbol _SQLAllocHandle@12
Debug/smc_client.exe : fatal error LNK1120: 3 unresolved externals
Error executing link.exe.
smc_client.exe - 4 error(s), 0 warning(s)
Thank you for helps...
|
|
|
|
|
Sounds you're not linking odbc32.lib.
Don't know right now how to add it exactly (in .NET -> project properties, Linker, Input, Additional Dependencies)
Succes!
|
|
|
|
|
Thank you.
Ahmet Orkun GEDiK
|
|
|
|
|
Hi all, I need a second opinion on this. Recently I've been struggling with trying to load user controls dynamically. Simple right. Well not if those user controls also host other user controls that are loaded dynamically. It's technically possible but all solutions I've seen so far haven't worked and they have been hacks. The main problem with loading user controls dynamically is keeping track of view state and wiring up events.
Now, one workaround I thought of was loading all the user controls at compile time (so that they are actually part of the page) and hiding/showing the desired controls depending on user input. I had thought that the resultant html source produced would end up becoming bloated with hidden controls. A quick test however, showed that the source ends up excluding all invisible controls, ie they are simply not rendered. So the resultant page is NOT bloated.
To prevent too much work being done on the server however, I thought you could test to see if the control was visible in which case you could safely call your data binding code for example, and if not, you simply do nothing when the control loads.
Well, what do you guys think? Is this how you do it as well? I'd like to hear pros and cons.
Regards
Senkwe
Just another wannabe code junky
|
|
|
|
|
Why in the HELL does WebForm designer restructure my nicely formated code in to a bunch of table tags?!?!
Original Code:
<DIV style="WIDTH: 873px; POSITION: relative; HEIGHT: 320px" ms_positioning="GridLayout">
<asp:button id="cmdUpdate" style="Z-INDEX: 101; LEFT: 584px; POSITION: absolute; TOP: 264px" tabIndex="10" runat="server" Width="80px" Height="24px" Text="Update"></asp:button>
<asp:label id="Label8" style="Z-INDEX: 102; LEFT: 400px; POSITION: absolute; TOP: 16px" runat="server" Width="136px">Welcome Message:</asp:label>
etc...
After changing just ONE item in the designer:
<DIV ms_positioning="GridLayout">
<TABLE height="320" cellSpacing="0" cellPadding="0" width="873" border="0" ms_2d_layout="TRUE">
<TR vAlign="top">
<TD width="0" height="1"></TD>
<TD width="8"></TD>
<TD width="8"></TD>
<TD width="168"></TD>
<TD width="88"></TD>
<TD width="16"></TD>
<TD width="112"></TD>
<TD width="184"></TD>
<TD width="88"></TD>
<TD width="201"></TD>
</TR>
<TR vAlign="top">
<TD width="0" height="15"></TD>
<TD colSpan="3" rowSpan="2">
<input id="hdnID" type="hidden" runat="server" NAME="hdnID"></TD>
<TD colSpan="8"></TD>
</TR>
<TR vAlign="top">
<TD width="0" height="24"></TD>
<TD rowSpan="10"></TD>
<TD colSpan="2">
<asp:label id="Label1" runat="server" Width="152px" Height="16px">Client Name:</asp:label></TD>
etc...
This makes no sense to me, and is EXTREMELY frustrating, because when I go back to the designer, everything is completely misplaced.
Thanks in advance for any ideas.
Jamie Nordmeyer
Portland, Oregon, USA
|
|
|
|
|
Hmmm, I've never experienced that.But I always use a simple HtmlTable for layout. If push comes to shove, you can try that instead.
Senkwe
Just another wannabe code junky
|
|
|
|
|
Thanks, Senkwe. Actually, I figured it out last night. Turns out that I'd somehow set my WebForm to target Internet Explorer 3.0 or below, and since those browsers don't support controls being layed on top of one another, it wraps them in table tags. None of my controls were overlapping, so I guess the designer was just playing it safe.
Jamie Nordmeyer
Portland, Oregon, USA
|
|
|
|
|
I want to display a value as hours which is stored as seconds in a database so I need to convert the value when I bind it to a textbox control. Something like this:
<asp:textbox id="hours" size="3" text='<%# DataBinder.Eval(Container.DataItem, "interval") / 3600 %>' runat="server" />
On the submit side it's easy enough to convert it back to seconds but I'm not sure how to convert it on the aspx side. I can probably change the sql statement but I would like to avoid that. I would also like to avoid having to do the conversion in the page_load function. Can this be done?
Todd Smith
|
|
|
|
|
The method I've used for this type of problem is to create a public method that formats the required output
<asp:textbox id="hours" size="3" text='<%# MyFunction(DataBinder.Eval(Container.DataItem, "interval", "{0}") )%>' runat="server" />
public string MyFunction(string strSeconds)
{
return int.Parse(strSeconds) / 3600;
}
|
|
|
|
|
That works. thx.
<asp:textbox id="hours" size="3" text='<%# Utils.SecsToHours(DataBinder.Eval(Container.DataItem, "hours").ToString()) %>' runat="server" />
public static string SecsToHours(string seconds)
{
try
{
int secs = Int32.Parse(seconds);
int hours = secs / 3600;
return hours.ToString();
}
catch
{
return "";
}
}
Todd Smith
|
|
|
|
|
HI,
IIS is being a twat. It won't let users download .exes from my web site. They user gets a 404 when the input the URL when I know for a fact that the files are there. Could it be some sort of security 'feature' that is causing this? I have run the IIS lockdown tool in the past - is it possible that this has affected it?
By the way, HTML, ASP, JPG, GIF all work fine.
Cheers
|
|
|
|