Hi,
pleas I need your help...
This is the error
...and this is all the code
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.Adapters;
using Oracle.DataAccess.Client;
using Telerik.OpenAccess.Config.Sql;
using System.Data;
using Telerik.Web.UI;
using System.Configuration;
using System.IO;
using System.Collections;
namespace WebApplication1
{
public partial class WebForm1 : System.Web.UI.Page
{
private OracleConnection conn = new OracleConnection();
string ConnString= "data source=OG_DB2;password=ghid101;user id=OG_GHIDONI";
string sql = " select tasso_iva, data_inizio, data_fine from tassi_iva group by tasso_iva, data_inizio, data_fine";
protected void Page_Load(object sender, EventArgs e)
{
string ConnString = "data source=OG_DB2;password=ghid101;user id=OG_GHIDONI";
conn.ConnectionString = ConnString; //ccc associo la connection string con un connection object
try
{
conn.Open(); //ccc apro la connessione
}
catch (Exception ex) // ccc catches any error
{
MessageBox.Show(ex.Message.ToString());
}
}
protected void Page_Init(object sender, EventArgs e)
{
RadListView1.NeedDataSource += (s, args) =>
{
RadListView1.DataSource = GetDataSet(sql);
// ccc il max per selezionare prima quello con la data d'inizio maggiore non gli piace! Trovare altra sol!!
};
}
protected void RadListView1_ItemUpdating(object sender, RadListViewCommandEventArgs e)
{
RadListViewEditableItem editedItem = (RadListViewEditableItem)e.ListViewItem;
Hashtable newValues = new Hashtable();
editedItem.ExtractValues(newValues);
DataTable IvaTable = RadListViewSource;
//Locate the changed row in the DataSource
DataRow[] changedRows = IvaTable.Select("tasso_iva = " + editedItem.GetDataKeyValue("tasso_iva"));
if (changedRows.Length != 1)
{
e.Canceled = true;
return;
}
//Update new values
changedRows[0].BeginEdit();
try
{
foreach (DictionaryEntry entry in newValues)
{
changedRows[0][(string)entry.Key] = entry.Value;
}
changedRows[0].EndEdit();
this.ViewState["lvds"] = IvaTable;
}
catch (Exception ex)
{
changedRows[0].CancelEdit();
//output a warning message as necessary
e.Canceled = true;
MessageBox.Show(ex.Message.ToString());
}
}
protected void RadListView1_ItemInserting(object sender, RadListViewCommandEventArgs e)
{
RadListViewEditableItem insertedItem = (RadListViewEditableItem)e.ListViewItem;
Hashtable newValues = new Hashtable();
insertedItem.ExtractValues(newValues);
DataTable IvaTable = RadListViewSource;
DataRow newRow = IvaTable.NewRow();
try
{
newRow["tasso_iva"] = IvaTable.Rows.Count + 1;
foreach (DictionaryEntry entry in newValues)
{
newRow[(string)entry.Key] = entry.Value;
}
IvaTable.Rows.Add(newRow);
this.ViewState["lvds"] = IvaTable;
}
catch (Exception ex)
{
//output a warning message as necessary
MessageBox.Show(ex.Message.ToString());
e.Canceled = true;
}
}
protected void RadListView1_ItemDeleting(object sender, RadListViewCommandEventArgs e)
{
try
{
DataTable IvaTable = this.RadListViewSource;
DataColumn pk = IvaTable.Columns["tasso_iva"];
DataColumn[] pkeys = new DataColumn[1];
pkeys[0] = pk;
IvaTable.PrimaryKey = pkeys;
int id = int.Parse(e.CommandArgument.ToString());
IvaTable.Rows.Find(id).Delete();
IvaTable.AcceptChanges();
this.ViewState["lvds"] = IvaTable;
}
catch (Exception ex)
{
//output a warning message as necessary
MessageBox.Show(ex.Message.ToString());
e.Canceled = true;
}
}
private DataTable RadListViewSource
{
get
{
Object obj = ViewState["lvds"];
if (obj != null)
{
return (DataTable)obj;
}
else
{
DataTable listViewDataSource;
listViewDataSource = new DataTable();
OracleDataAdapter adapter = new OracleDataAdapter(sql, ConnString);
adapter.Fill(listViewDataSource);
ViewState["lvds"] = listViewDataSource;
return listViewDataSource;
}
}
}
protected void RadListView1_NeedDataSource(object source, Telerik.Web.UI.RadListViewNeedDataSourceEventArgs e)
{
RadListView1.DataSource = GetDataSet(" select tasso_iva, max(data_inizio), data_fine from tassi_iva group by tasso_iva, data_inizio, data_fine");
//+ "where data_inizio = to_date('01.01.01', 'DD.MM.YY')";
}
public DataSet GetDataSet(string query)
{
string ConnString = "data source=OG_DB2;password=ghid101;user id=OG_GHIDONI";
//string qry = " select tasso_iva, max(data_inizio), data_fine from tassi_iva group by tasso_iva, data_inizio, data_fine";
OracleDataAdapter adapter = new OracleDataAdapter(query, ConnString);
DataSet ds = new DataSet();
try
{
adapter.Fill(ds, "tassi_iva");
}
finally
{
conn.Close();
}
return ds;
}
}
}
Somebody can help me?
Thanks a lot
pleas I need your help...
This is the error
...and this is all the code
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.Adapters;
using Oracle.DataAccess.Client;
using Telerik.OpenAccess.Config.Sql;
using System.Data;
using Telerik.Web.UI;
using System.Configuration;
using System.IO;
using System.Collections;
namespace WebApplication1
{
public partial class WebForm1 : System.Web.UI.Page
{
private OracleConnection conn = new OracleConnection();
string ConnString= "data source=OG_DB2;password=ghid101;user id=OG_GHIDONI";
string sql = " select tasso_iva, data_inizio, data_fine from tassi_iva group by tasso_iva, data_inizio, data_fine";
protected void Page_Load(object sender, EventArgs e)
{
string ConnString = "data source=OG_DB2;password=ghid101;user id=OG_GHIDONI";
conn.ConnectionString = ConnString; //ccc associo la connection string con un connection object
try
{
conn.Open(); //ccc apro la connessione
}
catch (Exception ex) // ccc catches any error
{
MessageBox.Show(ex.Message.ToString());
}
}
protected void Page_Init(object sender, EventArgs e)
{
RadListView1.NeedDataSource += (s, args) =>
{
RadListView1.DataSource = GetDataSet(sql);
// ccc il max per selezionare prima quello con la data d'inizio maggiore non gli piace! Trovare altra sol!!
};
}
protected void RadListView1_ItemUpdating(object sender, RadListViewCommandEventArgs e)
{
RadListViewEditableItem editedItem = (RadListViewEditableItem)e.ListViewItem;
Hashtable newValues = new Hashtable();
editedItem.ExtractValues(newValues);
DataTable IvaTable = RadListViewSource;
//Locate the changed row in the DataSource
DataRow[] changedRows = IvaTable.Select("tasso_iva = " + editedItem.GetDataKeyValue("tasso_iva"));
if (changedRows.Length != 1)
{
e.Canceled = true;
return;
}
//Update new values
changedRows[0].BeginEdit();
try
{
foreach (DictionaryEntry entry in newValues)
{
changedRows[0][(string)entry.Key] = entry.Value;
}
changedRows[0].EndEdit();
this.ViewState["lvds"] = IvaTable;
}
catch (Exception ex)
{
changedRows[0].CancelEdit();
//output a warning message as necessary
e.Canceled = true;
MessageBox.Show(ex.Message.ToString());
}
}
protected void RadListView1_ItemInserting(object sender, RadListViewCommandEventArgs e)
{
RadListViewEditableItem insertedItem = (RadListViewEditableItem)e.ListViewItem;
Hashtable newValues = new Hashtable();
insertedItem.ExtractValues(newValues);
DataTable IvaTable = RadListViewSource;
DataRow newRow = IvaTable.NewRow();
try
{
newRow["tasso_iva"] = IvaTable.Rows.Count + 1;
foreach (DictionaryEntry entry in newValues)
{
newRow[(string)entry.Key] = entry.Value;
}
IvaTable.Rows.Add(newRow);
this.ViewState["lvds"] = IvaTable;
}
catch (Exception ex)
{
//output a warning message as necessary
MessageBox.Show(ex.Message.ToString());
e.Canceled = true;
}
}
protected void RadListView1_ItemDeleting(object sender, RadListViewCommandEventArgs e)
{
try
{
DataTable IvaTable = this.RadListViewSource;
DataColumn pk = IvaTable.Columns["tasso_iva"];
DataColumn[] pkeys = new DataColumn[1];
pkeys[0] = pk;
IvaTable.PrimaryKey = pkeys;
int id = int.Parse(e.CommandArgument.ToString());
IvaTable.Rows.Find(id).Delete();
IvaTable.AcceptChanges();
this.ViewState["lvds"] = IvaTable;
}
catch (Exception ex)
{
//output a warning message as necessary
MessageBox.Show(ex.Message.ToString());
e.Canceled = true;
}
}
private DataTable RadListViewSource
{
get
{
Object obj = ViewState["lvds"];
if (obj != null)
{
return (DataTable)obj;
}
else
{
DataTable listViewDataSource;
listViewDataSource = new DataTable();
OracleDataAdapter adapter = new OracleDataAdapter(sql, ConnString);
adapter.Fill(listViewDataSource);
ViewState["lvds"] = listViewDataSource;
return listViewDataSource;
}
}
}
protected void RadListView1_NeedDataSource(object source, Telerik.Web.UI.RadListViewNeedDataSourceEventArgs e)
{
RadListView1.DataSource = GetDataSet(" select tasso_iva, max(data_inizio), data_fine from tassi_iva group by tasso_iva, data_inizio, data_fine");
//+ "where data_inizio = to_date('01.01.01', 'DD.MM.YY')";
}
public DataSet GetDataSet(string query)
{
string ConnString = "data source=OG_DB2;password=ghid101;user id=OG_GHIDONI";
//string qry = " select tasso_iva, max(data_inizio), data_fine from tassi_iva group by tasso_iva, data_inizio, data_fine";
OracleDataAdapter adapter = new OracleDataAdapter(query, ConnString);
DataSet ds = new DataSet();
try
{
adapter.Fill(ds, "tassi_iva");
}
finally
{
conn.Close();
}
return ds;
}
}
}
Somebody can help me?
Thanks a lot