// Save as a TXT file through Repeater
Protected void btn3_click (Object sender, eventargs e) {string sel = "select ex_parent, ex_postcode, ex_address from enterinfo where ex_mark like '%" + txtmark3.text. trim () + "% '"; datatable dt = sqlhelper. exectuetable (SEL); // retrieves a datatable
Rtinfo. datasource = DT; rtinfo. databind (); rtinfo. visible = true; string STR = ""; for (INT I = 0; I <this. rtinfo. items. count; I ++) {label labname = (Label) rtinfo. items [I]. findcontrol ("labname"); label labcode = (Label) rtinfo. items [I]. findcontrol ("labcode"); label labaddress = (Label) rtinfo. items [I]. findcontrol ("labaddress"); string VV = labname. text; STR = STR + (vv + ","); string vv1 = labcode. text; STR = STR + (vv1 + ","); string vv2 = labaddress. text; STR = STR + vv2; STR = STR + ("\ r \ n");} response. clear (); response. buffer = true; response. charset = "gb2312"; response. contentencoding = system. text. encoding. utf8; // string val = "online; filename = Consumption details" + String. format ("{0: yyyymmddhhmmss}", system. datetime. now) + ". TXT "; response. addheader ("content-disposition", "attachment; filename =" + server. urlencode ("Consumption details" + String. format ("{0: yyyymmddhhmmss}", system. datetime. now) + ". TXT "); // specifies that the returned stream cannot be read by the client. The response must be downloaded. contenttype = "text/plain"; // send the file stream to the client response. write (Str. tostring (); // stop page execution response. end ();}