salut les gars,
j'Ai probleme, mon datagrid ne me donne pas la possiblite ded'etiter les ranger je en comprends rien
dasn la fonction edit je recupere l'evenement et il me mondte bien que c'est la bonne ranger que je suis en train d'editer seulement
le resultat a l'ecrant le datagrid je se met pas en mode edition je ne comprends plus rien
voici mon code il n'y pas grand cose
quelcun aurais une idee pkoi ca ne marche pas
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120 using System; using System.Collections; using System.ComponentModel; using System.Data; using System.Drawing; using System.Web; using System.Web.SessionState; using System.Web.UI; using System.Web.UI.WebControls; using System.Web.UI.HtmlControls; using System.Data.OleDb; namespace test { /// <summary> /// Summary description for WebForm1. /// </summary> public class WebForm1 : System.Web.UI.Page { protected System.Web.UI.WebControls.DataGrid DataGrid1; private System.Data.OleDb.OleDbDataAdapter daProject; string connection="provider=Microsoft.JET.OLEDB.4.0;"+ "data source = C:\\Inetpub\\wwwroot\\WorkSheetProject\\Data\\Worksheet.mdb"; protected System.Web.UI.WebControls.DropDownList DropDownList1; protected System.Data.OleDb.OleDbCommand oleDbSelectCommand1; protected System.Data.OleDb.OleDbCommand oleDbInsertCommand1; protected System.Data.OleDb.OleDbCommand oleDbUpdateCommand1; protected System.Data.OleDb.OleDbCommand oleDbDeleteCommand1; protected System.Data.OleDb.OleDbConnection oleDbConnection1; protected test.dstest dstest; protected System.Data.OleDb.OleDbDataAdapter datestDll; protected System.Web.UI.HtmlControls.HtmlGenericControl spn; protected System.Web.UI.HtmlControls.HtmlGenericControl user; protected System.Web.UI.HtmlControls.HtmlGenericControl type; string commandString = "Select * from ProjectTarget where PrjID = @ID"; DataSet1 ds; int id { get{return Int32.Parse(ViewState["id"].ToString());} set{ ViewState["id"] = value;} } private void Page_Load(object sender, System.EventArgs e) { datestDll.Fill(dstest); daProject= new OleDbDataAdapter(commandString,connection); ds = new DataSet1(); daProject.SelectCommand.Parameters.Add(new OleDbParameter("@ID",OleDbType.SmallInt)); //id=Int32.Parse(DropDownList1.SelectedValue.ToString()); DataGrid1.DataSource=ds.ProjectTarget; DataGrid1.DataMember="ProjectTarget"; DataGrid1.DataKeyField="ID"; if(!IsPostBack) { DropDownList1.DataBind(); id=int.Parse(DropDownList1.SelectedValue.ToString()); } } private void DropDownList1_SelectedIndexChanged(object sender, System.EventArgs e) { // Put user code to initialize the page here daProject.SelectCommand.Parameters["@ID"].Value=DropDownList1.SelectedValue; id=int.Parse(DropDownList1.SelectedValue.ToString()); daProject.Fill(ds.ProjectTarget); DataGrid1.DataBind(); } private void CreatComponents() { daProject= new OleDbDataAdapter(commandString,connection); ds = new DataSet1(); daProject.SelectCommand.Parameters.Add(new OleDbParameter("@ID",OleDbType.SmallInt)); //id=Int32.Parse(DropDownList1.SelectedValue.ToString()); DataGrid1.DataSource=ds.ProjectTarget; DataGrid1.DataMember="ProjectTarget"; DataGrid1.DataKeyField="ID"; } private void DataGrid1_CancelCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e) { DataGrid1.SelectedIndex=-1; DataGrid1.DataBind(); } private void DataGrid1_UpdateCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e) { } private void DataGrid1_DeleteCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e) { } private void DataGrid1_EditCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e) { daProject.SelectCommand.Parameters["@ID"].Value=id; daProject.Fill(ds.ProjectTarget); DataGrid1.DataBind(); DataGrid1.SelectedIndex=e.Item.ItemIndex; DataGrid1.DataBind(); } } }
merci a vous
Partager