2014年7月13日 星期日

[RESOLVED] Detailsview with sqldatasource is not firing any event


Details View is not firing any event. below is my code for Details view with sqldatasource.


i have 2 datakeynames and they are mentioned in both detailsview and sqldatasource.


i have no clue where and what i missed. someone please shed light on this.  Thannk in advance.



                         DefaultMode="Edit" OnItemUpdated="dv1_itemupdated" OnItemCommand="dv1_itemcommand" CssClass="dg_details" BorderWidth="0"
>
































SelectCommand="select DYNAMIC_DATA_TYPE, FROM_VALUE, PRINT_VALUE, INSERT_DATE, UPDATE_DATE FROM DynamicDataTranslation
WHERE DYNAMIC_DATA_TYPE=@DYNAMIC_DATA_TYPE AND FROM_VALUE=@FROM_VALUE"
UpdateCommand="UPDATE DYNAMICDATATRANSLATION SET DYNAMIC_DATA_TYPE=@DYNAMICDATATYPE, FROM_VALUE=@FROMVALUE,
PRINT_VALUE=@PRINTVALUE, UPDATE_DATE=@UPDATE_DATE WHERE DYNAMIC_DATA_TYPE=@OLD_DDT AND FROM_VALUE=@OLD_FROMVAL"
ConnectionString="<%$ ConnectionStrings:conn_string_sql %>">


















can you the code of following events,


OnItemUpdated="dv1_itemupdated" OnItemCommand="dv1_itemcommand"

and the code, in which your the seting updaet parameters,


  







thanks







i coded those events. but control not at all firing these events.


having 2 datakey names causing the problem?



having 2 datakeys names cannot be the issue, but there is only one way to find out :)


temporarily use one datakey and check if event is raised or not 


thanks



yes it is firing for a single datakey.



I think your problem may be in:







I assume the dg1 is a GridView with 2 DataKeyNames.  I don't believe that the second SelectParameter (FROM_VALUE) is pulling the second DataKey.  Try changing your SelectParameters to:







 



Hi,


Thanks for your reply, i managed by creating a new column with Identity and using that as DataKeyNames.



here DYNAMIC_DATA_TYPE, FROM_VALUE  is a composite key.


and in DetailsView when i am trying to update.  i am validating through code if that combination existed i am not updating and i am exiting form DetialsView_itemcommand Event.


but if i enter existed data, control is exiting from event but it still hitting sqlDatasource update and throwing error.



any idea how to stop updating forcefully when duplicate data entered? any other way to resolve this?



Thanks


Narendra



i am validating in itemupdating event and cancelling if data already existed.


it is ok now.



thanks.


沒有留言:

張貼留言