<%@ Page Language="C#" %> <%@ Register TagPrefix="obout" Namespace="Obout.Grid" Assembly="obout_Grid_NET" %> <%@ Register TagPrefix="obout" Namespace="Obout.Interface" Assembly="obout_Interface" %> <%@ Register TagPrefix="obout" Namespace="Obout.SuperForm" Assembly="obout_SuperForm" %> <%@ Import Namespace="System.Data" %> <%@ Import Namespace="System.Data.OleDb" %> <%@ Import Namespace="System.Data.SqlClient" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <script language="C#" runat="server"> void Page_load(object sender, EventArgs e) { } void CreateGrid() { SqlConnection myConnection = new SqlConnection("Data Source=devsrv;Initial Catalog=devdb;User ID=peoplesoft;Password=11111"); string strSQL = "SELECT * FROM [patable_1]"; SqlDataAdapter ad = new SqlDataAdapter(strSQL, myConnection); DataSet ds = new DataSet(); ad.Fill(ds); grid1.DataSource = ds; grid1.DataBind(); } void DeleteRecord(object sender, GridRecordEventArgs e) { SqlConnection myConnection = new SqlConnection("Data Source=devsrv;Initial Catalog=devdb;User ID=peoplesoft;Password=11111"); string strSQL; strSQL = "delete from patable_1 " + " WHERE selectedCustomerTranId =" + e.Record["selectedCustomerTranId"]; SqlCommand cmd = new SqlCommand(strSQL, myConnection); cmd.Parameters.AddWithValue("@CustName", e.Record["CustName"]); cmd.Parameters.AddWithValue("@meetinglocation", e.Record["meetinglocation"]); myConnection.Open(); cmd.ExecuteNonQuery(); myConnection.Close(); } void UpdateRecord(object sender, GridRecordEventArgs e) { // Response.Redirect("saasas.aspx" + e.Record["selectedCustomerTranId"]); SqlConnection myConnection = new SqlConnection("Data Source=devsrv;Initial Catalog=devdb;User ID=peoplesoft;Password=11111"); string strSQL; strSQL = "update patable_1 set CustName=@CustName,meetinglocation=@meetinglocation" + " WHERE selectedCustomerTranId =" + e.Record["selectedCustomerTranId"]; SqlCommand cmd = new SqlCommand(strSQL, myConnection); cmd.Parameters.AddWithValue("@CustName", e.Record["CustName"]); cmd.Parameters.AddWithValue("@meetinglocation", e.Record["meetinglocation"]); myConnection.Open(); cmd.ExecuteNonQuery(); myConnection.Close(); } void InsertRecord(object sender, GridRecordEventArgs e) { } void RebindGrid(object sender, EventArgs e) { CreateGrid(); } </script> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title></title> </head> <body> <form id="form1" runat="server"> <div> <obout:Grid id="grid1" runat="server" EnableRecordHover="True" AutoGenerateColumns="false" DataSourceID="SqlDataSource1" OnEditCommand="UpdateRecord" OnRebind="RebindGrid" OnInsertCommand="InsertRecord" OnDeleteCommand="DeleteRecord" OnUpdateCommand="UpdateRecord" > <Columns> <obout:Column ID="Column1" DataField="selectedCustomerTranId" HeaderText="ORDER ID" runat="server"> <TemplateSettings RowEditTemplateControlId="txtselectedCustomerTranId" RowEditTemplateControlPropertyName="innerHTML"/> </obout:Column> <obout:Column ID="Column2" DataField="CustName" HeaderText="CustName" runat="server"> <TemplateSettings RowEditTemplateControlId="txtCustName" RowEditTemplateControlPropertyName="innerHTML"/> </obout:Column> <obout:Column ID="Column3" DataField="meetinglocation" HeaderText="meeting Location" runat="server"> <TemplateSettings RowEditTemplateControlId="txtmeetinglocation" RowEditTemplateControlPropertyName="innerHTML"/> </obout:Column> <obout:Column ID="Column4" HeaderText="EDIT" Width="200" AllowEdit="true" AllowDelete="true" runat="server" /> </Columns> <TemplateSettings RowEditTemplateId="tplRowEdit" /> <Templates> <obout:GridTemplate runat="server" ID="tplRowEdit"> <Template> <table class="rowEditTable"> <tr> <td valign="top"> <fieldset style="width: 275px; height: 175px;"> <legend>Ship Information</legend> <table> <tr> <td>Ship Name:</td> <td> <obout:OboutTextBox runat="server" ID="txtselectedCustomerTranId" Width="150" /> </td> </tr> <tr> <td>Ship Address:</td> <td> <obout:OboutTextBox runat="server" ID="txtCustName" Width="150" /> </td> </tr> <tr> <td>Ship City:</td> <td> <obout:OboutTextBox runat="server" ID="txtmeetinglocation" Width="150" /> </td> </tr> </table> </Template> </obout:GridTemplate> </Templates> </obout:Grid> <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionString1 %>" SelectCommand="SELECT * FROM [patable_1]"></asp:SqlDataSource> </div> </form> </body> </html> |
This is my Technical area of troubleshooting and learning new Programming skills and many more. Here you will find answers for many new technologies like asp.net 2.0/3.5,4.0 C# access, mysql, Amazon Webservice ,Sql-server, JD Edwards, SAS, Salesforce, APIs, MVC and many more. please visit & discuss.
Wednesday, February 16, 2011
Obout grid sample
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment