Gridview:
Label lbs = (Label) GridView1.Rows [I]. FindControl ("Label2 ");
String bn = (lbs. Text). ToString ();
TextBox tb1 = (TextBox) GridView1.Rows [I]. FindControl ("TextBox1 ");
Int count = Int32.Parse (tb1.Text );
Image Upload:
Protected void button#click (object sender, EventArgs e)
{
String bookname = bookTxt. Text;
Decimal price = Convert. ToDecimal (priceTxt. Text );
Int count = Convert. ToInt32 (countTxt. Text );
Int ID = DropDownList1.SelectedIndex + 1;
String Details = TextBox1.Text;
Try
{
ImageUpload1.Visible = true;
If (ImageUpload1.PostedFile. FileName = "")
{
Image. Text = "the file to be uploaded cannot be blank ";
Return;
}
Else
{
String filePath = ImageUpload1.PostedFile. FileName;
String fileName = filePath. Substring (filePath. LastIndexOf ("\") + 1 );
String serverPath = Server. MapPath (@"~ \ Images \ ") + fileName;
String relativepath = @"~ \ Images \ "+ fileName;
ImageUpload1.PostedFile. SaveAs (serverPath );
Image. Text = "uploaded successfully ";
Image1.ImageUrl = relativepath;
DB a = new DB ();
A. addBook (bookname, relativepath, price, ID, count, Details );
}
}
Catch (Exception err)
{
Image. Text = err. ToString ();
}
Datalist page:
Using system;
Using system. Data;
Using system. configuration;
Using system. Web;
Using system. Web. Security;
Using system. Web. UI;
Using system. Web. UI. webcontrols;
Using system. Web. UI. webcontrols. webparts;
Using system. Web. UI. htmlcontrols;
Using system. Data. sqlclient;
Class datalist page
{
Protected void page_load (Object sender, eventargs E)
{
If (! Page. ispostback)
{
Filldata ();
}
}
Static pageddatasource PPS;
Void filldata ()
{
Sqlconnection conn = new sqlconnection ("Data Source = 192.168.1.30; database = ticket_info_data; uid = sa; Password = sa; persist Security info = true ;");
Conn. open ();
Sqldataadapter SDA = new sqldataadapter ("select * From domesticflight", Conn );
Dataset DS = new dataset ();
SDA. Fill (DS );
PDS = new pageddatasource ();
PDS. datasource = Ds. Tables [0]. defaultview;
PPS. AllowPaging = true;
PPS. PageSize = 6;
This. DataList1.DataSource = Pds;
This. DataList1.DataBind ();
Conn. Close ();
}
// Next page
Protected void LinkButton2_Click (object sender, EventArgs e)
{
Pds. CurrentPageIndex ++;
This. DataList1.DataSource = Pds;
This. DataList1.DataBind ();
}
// Previous Page
Protected void linkbutton#click (Object sender, eventargs E)
{
PPS. currentpageindex --;
This. datalist1.datasource = PDS;
This. datalist1.databind ();
}
}
Datatable merge:
String book_id = request. querystring. Get ("book_id ");
DT. Add (book_id );
Datatable tablegetname = new datatable ();
DataTable table = new DataTable ();
BShowBookShop bsb = new BShowBookShop ();
DataTable [] tables = new DataTable [dt. Count];
Tablegetname = bsb. BLL_SelectBook (Book_Id );
For (int j = 0; j <tablegetname. Columns. Count; j ++)
{
Table. Columns. Add (tablegetname. Columns [j]. ColumnName );
}
Object [] obj = new object [table. Columns. Count];
For (int I = 0; I <dt. Count; I ++)
{
Tables [I] = bsb. BLL_SelectBook (dt [I]);
For (int j = 0; j <tables [I]. Rows. Count; j ++)
{
Tables [I]. Rows [j]. ItemArray. CopyTo (obj, 0 );
Table. Rows. Add (obj );
}
}
GridView1.DataSource = table;
GridView1.DataBind ();
GridView 72 TECH: http://blog.csdn.net/21aspnet/archive/2007/03/25/1540301.aspx
<Script language = "javascript" type = "text/javascript">
// Verify the user or password
Function Validate ()
{
If (document. all ('txtusername'). value = "")
{
Alert ('user name cannot be blank! ');
Document. all ('txtusername'). focus ();
Return false;
}
Else if (document. all ('txtpassword'). value = "")
{
Alert ('password cannot be blank! ');
Document. all ('txtpassword'). focus ();
Return false;
}
If (document. all. chkRememberMe. checked)
{
// Processing the expiration time
Var expdate = new Date ();
Expdate. setTime (expdate. getTime () + (365*24*60*60*1000 ));
SetCookie ("UserName", document.all.txt UserName. value, expdate );
SetCookie ("PassWord", document.all.txt Password. value, expdate );
} Else {
DeleteCookie ("UserName ");
DeleteCookie ("PassWord ");
}
Return true;
}
Function RemeberInfo ()
{
// Get cookie
// Debugger;
Var userCookie = GetCookie ("UserName ");
Var passCookie = GetCookie ("PassWord ");
If (usercookie = NULL) | (usercookie = "") | (passcookie = NULL) | (passcookie = "")){
Usercookie = "";
Passcookie = "";
Document. All. chkrememberme. Checked = false;
} Else {
Document. All. chkrememberme. Checked = true;
}
Document. getelementbyid ("txtusername"). value = usercookie;
Document.all.txt password. value = passcookie;
Document. All. btnlogion. Focus ();
}
</SCRIPT>
<Script language = "Javascript" src = "Scripts/common. js" type = "text/javascript" charset = "gb2312"> </script>
<Script language = "javascript" type = "text/javascript">
// Initialization
Function Init ()
{
Document. getElementById ("txtUserName"). focus ();
RemeberInfo ();
}
// Open a new window and maximize display
Function openWindow (url)
{
// Set window properties
Var top = 0;
Var left = 0;
Var width = screen. availWidth-10;
Var height = screen. availHeight-30;
// Close the logon window
Window. opener = null;
Window. open ("", "_ self ");
Window. close ();
// Open the page
Window. open (url, "", "scrollbars = yes, status = yes, toolbar = no, menubar = no, location = no, width =" + width + ", height = "+ height +", top = "+ top +", left = "+ left );
}
// Delete Cookies
Function delCookie ()
{
DeleteCookie ("UserName ");
DeleteCookie ("PassWord ");
}
</Script>
Use js directly on the page:
Else
{
Page. ClientScript. RegisterStartupScript (this. GetType (), "Info", "<script> alert ('Sorry, you have not logged on or the operation has timed out! '); Window. close (); window. open ('default. aspx'); </script> ");
}