Link to home
Start Free TrialLog in
Avatar of SirReadAlot
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_currency_conversion";
                  OracleConnection con = new  OracleConnection(connectionString);
                  //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.CurrentPageIndex=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

 
ASKER CERTIFIED SOLUTION
Avatar of cupawntae
cupawntae

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of SirReadAlot
SirReadAlot

ASKER

will try it now, was in a meeting
thanks mate it works

cheers

SirReadAlot
No probs! Thanks for the points! :)