ASP.NET development skills five (reposted)

xiaoxiao2021-03-06  40

Question 1: Established a DataGrid, then established a button column in the DataGrid, you can get the ID value of the currently selected button, then you can pass this ID value, get other field content displayed outside DataGrid? ? Currently, you can re-do DataReader to query according to ID, but I want to get it by calling a property of DataSet, I don't know if it is correct? How should I do?

A: DS.Tables ("TableName"). Rows (i) .Item ("ColumnName"). Tostring ()

Question 2: Want to implement on the table of Table generated with DataGurd, the function of automatically changing the color of the mouse

A: Item.arributes ["onmouseover"] = ....

Question 3: How to check if a file exists in a directory in ASP.NET, what function or method is used

answer:

IF (Not Directory.exists ("Directory Address)).

Directory.createdIRectory ("directory address")

END IF

Question 4: Upload big files with ASP.NET

A: We have encountered such or such problems when we go upload big files. Setting big maxRequestLength values ​​do not completely solve the problem, because the ASP.NET will block until the entire file is loaded into memory. In fact, if the files are large, we often see Internet Explorer display "The page cannot be displayed - cannot Find Server or DNS ERROR", it seems to be Catch can't. why? Because this is a Client Side error, the Application_ERROR of the Server Side is not processed, and you can refer to this post to study the mechanism of generating this error.

Handling Server Error When Upload File Too Large

The solution is to use the implicit HttpWorkerRequest, and use its getPreLoadedEntityBody and ReadentityBody methods to read data from IIS for ASP.NET.

IServiceProvider Provider = (iServiceProvider) HTTPCONTEXT.CURRENT;

HttpWorkerRequest WR = (httpWorkerRequest) provider.getService (TypeOf (httpWorkerRequest);

BYTE [] BS = Wr.GetPreeloadedEntityBody ();

....

IF (! wr.isentirentitybodyispreloaded ())

{

INT n = 1024;

Byte [] bs2 = new byte [n];

While (Wr.ReadentityBody (BS2, N)> 0)

{

.....

}

}

转载请注明原文地址:https://www.9cbs.com/read-53390.html

New Post(0)