SirReadAlot
asked on
displaying user friendly msg, when record is not found
Hi experts,
just a slight problem here.
I have a fully functional datagrid, that searches for data and fills the datagrid with the answer.
However, when there isn't any data i just what to display a "msg not found" how do i actuall accomplish this.
thanks guys.
see code
private void btnGo_Click(object sender, System.EventArgs e)
{
//Connection string to the database
string connectionString = "server=TTTD.WORLD;User ID=ttt_currency_conversion ;Password= ttt_curren cy_convers ion";
OracleConnection con = new OracleConnection(connectio nString);
//select statement
string ora =
" SELECT GBP_EXCHANGE_PID, ISO_CODE, DATE_STAMP, EXCHANGE_RATE " +
" FROM GBP_CURRENCY_RATES " +
" WHERE ISO_CODE LIKE'%" + this.txtFind.Text.ToUpper( ) +"%' "; //used upper for small letter entry
//use an adapter in a disconnected enviroment
OracleDataAdapter adapter = new OracleDataAdapter(ora, connectionString);
//initialise the dataset for the adapter to use
DataSet ds = new DataSet();
//fill the dataset
adapter.Fill(ds);
//stop the paging index from miscalculating its position
//gets data and binds it to the grid
DgExchange.CurrentPageInde x=0;
DgExchange.DataSource=ds;
DgExchange.DataBind();
//close connection
con.Close();
}
i tried using my old vb.net code but c# does not have the with keyword
If dv.Count > 0 Then
With DgRoles
'stops
.CurrentPageIndex = 0
.DataSource = dv
.DataMember = "Roles"
.DataKeyField = "Roleid"
DgRoles.DataBind()
End With
Else
'If no results, show message in label
lblError.Text = "No Records Found. Please search again"
End If
just a slight problem here.
I have a fully functional datagrid, that searches for data and fills the datagrid with the answer.
However, when there isn't any data i just what to display a "msg not found" how do i actuall accomplish this.
thanks guys.
see code
private void btnGo_Click(object sender, System.EventArgs e)
{
//Connection string to the database
string connectionString = "server=TTTD.WORLD;User ID=ttt_currency_conversion
OracleConnection con = new OracleConnection(connectio
//select statement
string ora =
" SELECT GBP_EXCHANGE_PID, ISO_CODE, DATE_STAMP, EXCHANGE_RATE " +
" FROM GBP_CURRENCY_RATES " +
" WHERE ISO_CODE LIKE'%" + this.txtFind.Text.ToUpper(
//use an adapter in a disconnected enviroment
OracleDataAdapter adapter = new OracleDataAdapter(ora, connectionString);
//initialise the dataset for the adapter to use
DataSet ds = new DataSet();
//fill the dataset
adapter.Fill(ds);
//stop the paging index from miscalculating its position
//gets data and binds it to the grid
DgExchange.CurrentPageInde
DgExchange.DataSource=ds;
DgExchange.DataBind();
//close connection
con.Close();
}
i tried using my old vb.net code but c# does not have the with keyword
If dv.Count > 0 Then
With DgRoles
'stops
.CurrentPageIndex = 0
.DataSource = dv
.DataMember = "Roles"
.DataKeyField = "Roleid"
DgRoles.DataBind()
End With
Else
'If no results, show message in label
lblError.Text = "No Records Found. Please search again"
End If
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
thanks mate it works
cheers
SirReadAlot
cheers
SirReadAlot
No probs! Thanks for the points! :)
ASKER