J’ai un RadGrid, chaque row de mon RadGrid contient un ComboBox.
En faisant rowDropping, j’ai besoin de trouver la valeur de combobox dans mon row avant rowdroped.
Voilà l’exemple :
<%@ Page Language="C#" %>
<%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Test</title>
<script runat="server">
protected void RadGrid1_NeedDataSource(object source, GridNeedDataSourceEventArgs e)
{
((RadGrid)source).DataSource = new[] { new { ID = 1 }, new { ID = 2 } };
}
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:ScriptManager runat="server" ID="ScriptManager1" />
<telerik:RadGrid runat="server" ID="RadGrid1" OnNeedDataSource="RadGrid1_NeedDataSource"
AutoGenerateColumns="false">
<MasterTableView>
<Columns>
<telerik:GridTemplateColumn>
<ItemTemplate>
<telerik:RadComboBox runat="server" ID="RadComboBox1" DataTextField="CategoryName"
DataValueField="CategoryID" DataSourceID="SqlDataSource1" selectedValue='<%#Eval("ID") %>'/>
</ItemTemplate>
</telerik:GridTemplateColumn>
</Columns>
</MasterTableView>
<ClientSettings AllowRowsDragDrop="true">
<ClientEvents OnRowDropping="rowDropping" />
<Selecting AllowRowSelect="true" />
</ClientSettings>
</telerik:RadGrid>
</asp:SqlDataSource runat="server" ID="SqlDataSource1" ConnectionString="Data Source=.\SQLEXPRESS;Initial Catalog=Northwind;Integrated Security=True"
SelectCommand="Select * From Categories">
<script type="text/javascript">
function rowDropping(sender,args) {
var firstDraggedItem=args.get_draggedItems()[0];
var radComboBox=firstDraggedItem.findControl("RadComboBox1");
if(radComboBox) {
alert(radComboBox.get_selectedItem().get_value());
}
}
</script>
</div>
</form>
</body>
</html>
Hello
Pour utiliser des dlls de ressources ou tout autre contenu/dll, il faut penser à ajouter ces dlls spécifiquement dans le répertoire d’exécution des Tests Unitaires.
Pour le préciser il faut utiliser le menu « Test » > « Edit Test Run Configuration » > « LocalTestRun.testrunconfig » de Visual Studio et préciser. Par exemple pour faire simple on peut déployer tout le répertoire bin\debug qui contient en particulier les répertoire de ressources.
Une fois cela fait, le test unitaire marche.
Voir la documentation Microsoft associée à l’utilisation de tests unitaires :
http://msdn.microsoft.com/fr-fr/library/ms182474(VS.80).aspx#LocalDeploymentFolders
Good test !
J’ai activé StyleCop et FxCop pour prendre des bonnes habitudes de développement !!!
Mais il y a des conflits entre GuideLines et StyleCop !!
Par exemple :
1.
GuideLine : Les variables membres sont préfixées par _
StyleCop : Warning:SA1306: Variable names must start with a lower-case letter: _Pages.
(StyleCop ne précise pas les différences entre les variables membres et les autres variables.)
2.
Je dois utiliser le “this.” Pour tous les variables membres et toutes les méthodes !!
SA1101: The call to AddPage must begin with the 'this.' prefix to indicate that the item is a member of the class.
3.
Sur un Event généré par VS il donne des warnings :
SA1300: method names begin with an upper-case letter: btnCancel_Click.
Bon je désactive les certains règles de StyleCop. Avez-vous l’autre solution ??
Par contre FxCop est très bien
J