tags:

views:

667

answers:

1

Hi...

I'm using the obout grid control in c# and not to sure how to throw an error from the code behind!

I am catching the error in the code behind with a try catch block (which i can see it doing using break points in visual studio) which I am creating on purpose from the database(creating another record with the same identifier), but cant seem to make it bring up a message box with an error!

Here's the code I am working with:

     void InsertRecord(object sender, GridRecordEventArgs e)
     {            
        try
        {
            string[] value = new string[] {/*records to be added */};

            connClass func = new connClass();

            func.fnRecord(value, "rm_category_add");

        }

        catch (Exception ne)
        {

             //here's the problem!!!!!!              
        }

    }

I have also set the onCallbackerror to true as you can see here:

    protected void Page_Load(object sender, EventArgs e)
    {
        grid1.ID = "grid1";
        grid1.CallbackMode = true;
        grid1.Serialize = true;
        grid1.AutoGenerateColumns = false;
        grid1.AllowAddingRecords = true;
        grid1.ShowLoadingMessage = true;
        grid1.FolderStyle = "../css/style_13";
        grid1.ClientSideEvents.OnClientCallback = "OnClientCallback";
        grid1.ClientSideEvents.OnClientCallbackError = "onCallbackError";            
        grid1.ClientSideEvents.OnClientDblClick = "fn_UpdateRecord";             
     }

Any Help would be appreciated:)

A: 

I am not sure if you can do that in callback mode.

But you can capture and display the error in javascript using the callbackerror function. You can set the error message to display in a div on the clientside. I think obout has a sample here http://www.obout.com/grid/KnowledgeBase.aspx?id=256

I am not sure if this is exactly what you are looking for but hope it helps.

<script type"text/javascript">
 function onCallbackError(errorMessage, commandType, recordIndex, data) {
   alert(errorMessage);
 }
 </script>
kushin