首页新闻找找看学习计划

不能理解FormView1中使用DataSource绑定数据源出现的问题

0
悬赏园豆:30 [已关闭问题]
<p class="MsoNormal" style="margin: 0cm 0cm 0pt;"><span style="font-size: small;"><span style="font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman';">使用</span><span lang="EN-US"><span style="font-family: Times New Roman;">MS Web</span></span><span style="font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman';">控件时总是会碰到这样那样的问题</span><span lang="EN-US"><span style="font-family: Times New Roman;">,</span></span><span style="font-family: 宋体; mso-ascii-font-family: 'Times New Roman'; mso-hansi-font-family: 'Times New Roman';">由于对原理不是很清楚。一下是我在使用</span></span><span style="font-size: 9pt; color: blue; font-family: 新宋体; mso-hansi-font-family: 'Times New Roman'; mso-font-kerning: 0pt; mso-no-proof: yes;" lang="EN-US">DataSource</span><span style="font-size: 9pt; color: blue; font-family: 新宋体; mso-hansi-font-family: 'Times New Roman'; mso-font-kerning: 0pt; mso-no-proof: yes;">做<span lang="EN-US">FormView1</span>数据源遇到的问题。<span lang="EN-US"></span></span></p> <p class="MsoNormal" style="margin: 0cm 0cm 0pt;"><span style="font-size: 9pt; color: blue; font-family: 新宋体; mso-hansi-font-family: 'Times New Roman'; mso-font-kerning: 0pt; mso-no-proof: yes;">前提<span lang="EN-US"></span></span></p> <p class="MsoNormal" style="margin: 0cm 0cm 0pt;"><span style="font-size: 9pt; color: blue; font-family: 新宋体; mso-hansi-font-family: 'Times New Roman'; mso-font-kerning: 0pt; mso-no-proof: yes;">前台代码:<span lang="EN-US"></span></span></p> <p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: left; mso-layout-grid-align: none;" align="left"><span style="font-size: 9pt; color: blue; font-family: 新宋体; mso-hansi-font-family: 'Times New Roman'; mso-font-kerning: 0pt; mso-no-proof: yes;" lang="EN-US"><span style="mso-spacerun: yes;">&nbsp; </span></span><span style="font-size: 9pt; font-family: 新宋体; mso-hansi-font-family: 'Times New Roman'; mso-font-kerning: 0pt; mso-no-proof: yes;" lang="EN-US"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: blue;">&lt;</span><span style="color: maroon;">div</span><span style="color: blue;">&gt;</span></span></p> <p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: left; mso-layout-grid-align: none;" align="left"><span style="font-size: 9pt; font-family: 新宋体; mso-hansi-font-family: 'Times New Roman'; mso-font-kerning: 0pt; mso-no-proof: yes;" lang="EN-US"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="color: blue;">&lt;</span><span style="color: maroon;">asp</span><span style="color: blue;">:</span><span style="color: maroon;">FormView</span> <span style="color: red;">ID</span><span style="color: blue;">="FormView1"</span> <span style="color: red;">runat</span><span style="color: blue;">="server"</span> <span style="color: red;">DataKeyNames</span><span style="color: blue;">="CategoryID"</span><span style="mso-spacerun: yes;">&nbsp; </span><span style="color: red;">OnItemCommand</span><span style="color: blue;">="FormView1_ItemCommand"</span> <span style="color: red;">OnItemUpdating</span><span style="color: blue;">="FormView1_ItemUpdating"</span> <span style="color: red;">OnItemUpdated</span><span style="color: blue;">="FormView1_ItemUpdated"</span> <span style="color: red;">OnModeChanging</span><span style="color: blue;">="FormView1_ModeChanging"&gt;</span></span></p> <p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: left; mso-layout-grid-align: none;" align="left"><span style="font-size: 9pt; font-family: 新宋体; mso-hansi-font-family: 'Times New Roman'; mso-font-kerning: 0pt; mso-no-proof: yes;" lang="EN-US"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="color: blue;">&lt;</span><span style="color: maroon;">EditItemTemplate</span><span style="color: blue;">&gt;</span></span></p> <p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: left; mso-layout-grid-align: none;" align="left"><span style="font-size: 9pt; font-family: 新宋体; mso-hansi-font-family: 'Times New Roman'; mso-font-kerning: 0pt; mso-no-proof: yes;" lang="EN-US"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>CategoryID:</span></p> <p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: left; mso-layout-grid-align: none;" align="left"><span style="font-size: 9pt; font-family: 新宋体; mso-hansi-font-family: 'Times New Roman'; mso-font-kerning: 0pt; mso-no-proof: yes;" lang="EN-US"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="color: blue;">&lt;</span><span style="color: maroon;">asp</span><span style="color: blue;">:</span><span style="color: maroon;">Label</span> <span style="color: red;">ID</span><span style="color: blue;">="CategoryIDLabel1"</span> <span style="color: red;">runat</span><span style="color: blue;">="server"</span> <span style="color: red;">Text</span><span style="color: blue;">='</span><span style="background: yellow; mso-highlight: yellow;">&lt;%</span># Eval("CategoryID") <span style="background: yellow; mso-highlight: yellow;">%&gt;</span><span style="color: blue;">'&gt;&lt;/</span><span style="color: maroon;">asp</span><span style="color: blue;">:</span><span style="color: maroon;">Label</span><span style="color: blue;">&gt;&lt;</span><span style="color: maroon;">br</span> <span style="color: blue;">/&gt;</span></span></p> <p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: left; mso-layout-grid-align: none;" align="left"><span style="font-size: 9pt; font-family: 新宋体; mso-hansi-font-family: 'Times New Roman'; mso-font-kerning: 0pt; mso-no-proof: yes;" lang="EN-US"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>CategoryName:</span></p> <p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: left; mso-layout-grid-align: none;" align="left"><span style="font-size: 9pt; font-family: 新宋体; mso-hansi-font-family: 'Times New Roman'; mso-font-kerning: 0pt; mso-no-proof: yes;" lang="EN-US"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="color: blue;">&lt;</span><span style="color: maroon;">asp</span><span style="color: blue;">:</span><span style="color: maroon;">TextBox</span> <span style="color: red;">ID</span><span style="color: blue;">="CategoryNameTextBox"</span> <span style="color: red;">runat</span><span style="color: blue;">="server"</span> <span style="color: red;">Text</span><span style="color: blue;">='</span><span style="background: yellow; mso-highlight: yellow;">&lt;%</span># Bind("CategoryName") <span style="background: yellow; mso-highlight: yellow;">%&gt;</span><span style="color: blue;">'&gt;&lt;/</span><span style="color: maroon;">asp</span><span style="color: blue;">:</span><span style="color: maroon;">TextBox</span><span style="color: blue;">&gt;&lt;</span><span style="color: maroon;">br</span> <span style="color: blue;">/&gt;</span></span></p> <p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: left; mso-layout-grid-align: none;" align="left"><span style="font-size: 9pt; font-family: 新宋体; mso-hansi-font-family: 'Times New Roman'; mso-font-kerning: 0pt; mso-no-proof: yes;" lang="EN-US"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>Description:</span></p> <p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: left; mso-layout-grid-align: none;" align="left"><span style="font-size: 9pt; font-family: 新宋体; mso-hansi-font-family: 'Times New Roman'; mso-font-kerning: 0pt; mso-no-proof: yes;" lang="EN-US"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="color: blue;">&lt;</span><span style="color: maroon;">asp</span><span style="color: blue;">:</span><span style="color: maroon;">TextBox</span> <span style="color: red;">ID</span><span style="color: blue;">="DescriptionTextBox"</span> <span style="color: red;">runat</span><span style="color: blue;">="server"</span> <span style="color: red;">Text</span><span style="color: blue;">='</span><span style="background: yellow; mso-highlight: yellow;">&lt;%</span># Bind("Description") <span style="background: yellow; mso-highlight: yellow;">%&gt;</span><span style="color: blue;">'&gt;&lt;/</span><span style="color: maroon;">asp</span><span style="color: blue;">:</span><span style="color: maroon;">TextBox</span><span style="color: blue;">&gt;&lt;</span><span style="color: maroon;">br</span> <span style="color: blue;">/&gt;</span></span></p> <p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: left; mso-layout-grid-align: none;" align="left"><span style="font-size: 9pt; font-family: 新宋体; mso-hansi-font-family: 'Times New Roman'; mso-font-kerning: 0pt; mso-no-proof: yes;" lang="EN-US"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="color: blue;">&lt;</span><span style="color: maroon;">asp</span><span style="color: blue;">:</span><span style="color: maroon;">LinkButton</span> <span style="color: red;">ID</span><span style="color: blue;">="UpdateButton"</span> <span style="color: red;">runat</span><span style="color: blue;">="server"</span> <span style="color: red;">CausesValidation</span><span style="color: blue;">="True"</span> <span style="color: red;">CommandName</span><span style="color: blue;">="Update"</span></span></p> <p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: left; mso-layout-grid-align: none;" align="left"><span style="font-size: 9pt; font-family: 新宋体; mso-hansi-font-family: 'Times New Roman'; mso-font-kerning: 0pt; mso-no-proof: yes;" lang="EN-US"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="color: red;">Text</span><span style="color: blue;">="</span></span><span style="font-size: 9pt; color: blue; font-family: 新宋体; mso-hansi-font-family: 'Times New Roman'; mso-font-kerning: 0pt; mso-no-proof: yes;">更新<span lang="EN-US">"&gt;&lt;/</span></span><span style="font-size: 9pt; color: maroon; font-family: 新宋体; mso-hansi-font-family: 'Times New Roman'; mso-font-kerning: 0pt; mso-no-proof: yes;" lang="EN-US">asp</span><span style="font-size: 9pt; color: blue; font-family: 新宋体; mso-hansi-font-family: 'Times New Roman'; mso-font-kerning: 0pt; mso-no-proof: yes;" lang="EN-US">:</span><span style="font-size: 9pt; color: maroon; font-family: 新宋体; mso-hansi-font-family: 'Times New Roman'; mso-font-kerning: 0pt; mso-no-proof: yes;" lang="EN-US">LinkButton</span><span style="font-size: 9pt; color: blue; font-family: 新宋体; mso-hansi-font-family: 'Times New Roman'; mso-font-kerning: 0pt; mso-no-proof: yes;" lang="EN-US">&gt;</span></p> <p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: left; mso-layout-grid-align: none;" align="left"><span style="font-size: 9pt; font-family: 新宋体; mso-hansi-font-family: 'Times New Roman'; mso-font-kerning: 0pt; mso-no-proof: yes;" lang="EN-US"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="color: blue;">&lt;</span><span style="color: maroon;">asp</span><span style="color: blue;">:</span><span style="color: maroon;">LinkButton</span> <span style="color: red;">ID</span><span style="color: blue;">="UpdateCancelButton"</span> <span style="color: red;">runat</span><span style="color: blue;">="server"</span> <span style="color: red;">CausesValidation</span><span style="color: blue;">="False"</span> <span style="color: red;">CommandName</span><span style="color: blue;">="Cancel"</span></span></p> <p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: left; mso-layout-grid-align: none;" align="left"><span style="font-size: 9pt; font-family: 新宋体; mso-hansi-font-family: 'Times New Roman'; mso-font-kerning: 0pt; mso-no-proof: yes;" lang="EN-US"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="color: red;">Text</span><span style="color: blue;">="</span></span><span style="font-size: 9pt; color: blue; font-family: 新宋体; mso-hansi-font-family: 'Times New Roman'; mso-font-kerning: 0pt; mso-no-proof: yes;">取消<span lang="EN-US">"&gt;&lt;/</span></span><span style="font-size: 9pt; color: maroon; font-family: 新宋体; mso-hansi-font-family: 'Times New Roman'; mso-font-kerning: 0pt; mso-no-proof: yes;" lang="EN-US">asp</span><span style="font-size: 9pt; color: blue; font-family: 新宋体; mso-hansi-font-family: 'Times New Roman'; mso-font-kerning: 0pt; mso-no-proof: yes;" lang="EN-US">:</span><span style="font-size: 9pt; color: maroon; font-family: 新宋体; mso-hansi-font-family: 'Times New Roman'; mso-font-kerning: 0pt; mso-no-proof: yes;" lang="EN-US">LinkButton</span><span style="font-size: 9pt; color: blue; font-family: 新宋体; mso-hansi-font-family: 'Times New Roman'; mso-font-kerning: 0pt; mso-no-proof: yes;" lang="EN-US">&gt;</span></p> <p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: left; mso-layout-grid-align: none;" align="left"><span style="font-size: 9pt; font-family: 新宋体; mso-hansi-font-family: 'Times New Roman'; mso-font-kerning: 0pt; mso-no-proof: yes;" lang="EN-US"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="color: blue;">&lt;</span><span style="color: maroon;">asp</span><span style="color: blue;">:</span><span style="color: maroon;">Button</span> <span style="color: red;">ID</span><span style="color: blue;">="Button2"</span> <span style="color: red;">runat</span><span style="color: blue;">="server"</span> <span style="color: red;">Text</span><span style="color: blue;">="</span></span><span style="font-size: 9pt; color: blue; font-family: 新宋体; mso-hansi-font-family: 'Times New Roman'; mso-font-kerning: 0pt; mso-no-proof: yes;">更新<span lang="EN-US">"</span></span><span style="font-size: 9pt; font-family: 新宋体; mso-hansi-font-family: 'Times New Roman'; mso-font-kerning: 0pt; mso-no-proof: yes;" lang="EN-US"> <span style="color: red;">CausesValidation</span><span style="color: blue;">="true"</span> <span style="color: red;">CommandName</span><span style="color: blue;">="Update"</span> <span style="color: blue;">/&gt;</span></span></p> <p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: left; mso-layout-grid-align: none;" align="left"><span style="font-size: 9pt; font-family: 新宋体; mso-hansi-font-family: 'Times New Roman'; mso-font-kerning: 0pt; mso-no-proof: yes;" lang="EN-US"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="color: blue;">&lt;</span><span style="color: maroon;">asp</span><span style="color: blue;">:</span><span style="color: maroon;">Button</span> <span style="color: red;">ID</span><span style="color: blue;">="Button3"</span> <span style="color: red;">runat</span><span style="color: blue;">="server"</span> <span style="color: red;">Text</span><span style="color: blue;">="</span></span><span style="font-size: 9pt; color: blue; font-family: 新宋体; mso-hansi-font-family: 'Times New Roman'; mso-font-kerning: 0pt; mso-no-proof: yes;">取消<span lang="EN-US">"</span></span><span style="font-size: 9pt; font-family: 新宋体; mso-hansi-font-family: 'Times New Roman'; mso-font-kerning: 0pt; mso-no-proof: yes;" lang="EN-US"> <span style="color: red;">CausesValidation</span><span style="color: blue;">="false"</span> <span style="color: red;">CommandName</span><span style="color: blue;">="Cancel"</span> <span style="color: blue;">/&gt;</span></span></p> <p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: left; mso-layout-grid-align: none;" align="left"><span style="font-size: 9pt; font-family: 新宋体; mso-hansi-font-family: 'Times New Roman'; mso-font-kerning: 0pt; mso-no-proof: yes;" lang="EN-US"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="color: blue;">&lt;/</span><span style="color: maroon;">EditItemTemplate</span><span style="color: blue;">&gt;</span></span></p> <p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: left; mso-layout-grid-align: none;" align="left"><span style="font-size: 9pt; font-family: 新宋体; mso-hansi-font-family: 'Times New Roman'; mso-font-kerning: 0pt; mso-no-proof: yes;" lang="EN-US"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="color: blue;">&lt;</span><span style="color: maroon;">ItemTemplate</span><span style="color: blue;">&gt;</span></span></p> <p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: left; mso-layout-grid-align: none;" align="left"><span style="font-size: 9pt; font-family: 新宋体; mso-hansi-font-family: 'Times New Roman'; mso-font-kerning: 0pt; mso-no-proof: yes;" lang="EN-US"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>CategoryID:</span></p> <p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: left; mso-layout-grid-align: none;" align="left"><span style="font-size: 9pt; font-family: 新宋体; mso-hansi-font-family: 'Times New Roman'; mso-font-kerning: 0pt; mso-no-proof: yes;" lang="EN-US"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="color: blue;">&lt;</span><span style="color: maroon;">asp</span><span style="color: blue;">:</span><span style="color: maroon;">Label</span> <span style="color: red;">ID</span><span style="color: blue;">="CategoryIDLabel"</span> <span style="color: red;">runat</span><span style="color: blue;">="server"</span> <span style="color: red;">Text</span><span style="color: blue;">='</span><span style="background: yellow; mso-highlight: yellow;">&lt;%</span># Eval("CategoryID") <span style="background: yellow; mso-highlight: yellow;">%&gt;</span><span style="color: blue;">'&gt;&lt;/</span><span style="color: maroon;">asp</span><span style="color: blue;">:</span><span style="color: maroon;">Label</span><span style="color: blue;">&gt;&lt;</span><span style="color: maroon;">br</span> <span style="color: blue;">/&gt;</span></span></p> <p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: left; mso-layout-grid-align: none;" align="left"><span style="font-size: 9pt; font-family: 新宋体; mso-hansi-font-family: 'Times New Roman'; mso-font-kerning: 0pt; mso-no-proof: yes;" lang="EN-US"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>CategoryName:</span></p> <p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: left; mso-layout-grid-align: none;" align="left"><span style="font-size: 9pt; font-family: 新宋体; mso-hansi-font-family: 'Times New Roman'; mso-font-kerning: 0pt; mso-no-proof: yes;" lang="EN-US"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="color: blue;">&lt;</span><span style="color: maroon;">asp</span><span style="color: blue;">:</span><span style="color: maroon;">Label</span> <span style="color: red;">ID</span><span style="color: blue;">="CategoryNameLabel"</span> <span style="color: red;">runat</span><span style="color: blue;">="server"</span> <span style="color: red;">Text</span><span style="color: blue;">='</span><span style="background: yellow; mso-highlight: yellow;">&lt;%</span># Bind("CategoryName") <span style="background: yellow; mso-highlight: yellow;">%&gt;</span><span style="color: blue;">'&gt;&lt;/</span><span style="color: maroon;">asp</span><span style="color: blue;">:</span><span style="color: maroon;">Label</span><span style="color: blue;">&gt;&lt;</span><span style="color: maroon;">br</span> <span style="color: blue;">/&gt;</span></span></p> <p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: left; mso-layout-grid-align: none;" align="left"><span style="font-size: 9pt; font-family: 新宋体; mso-hansi-font-family: 'Times New Roman'; mso-font-kerning: 0pt; mso-no-proof: yes;" lang="EN-US"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>Description:</span></p> <p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: left; mso-layout-grid-align: none;" align="left"><span style="font-size: 9pt; font-family: 新宋体; mso-hansi-font-family: 'Times New Roman'; mso-font-kerning: 0pt; mso-no-proof: yes;" lang="EN-US"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;</span><span style="color: blue;">&lt;</span><span style="color: maroon;">asp</span><span style="color: blue;">:</span><span style="color: maroon;">Label</span> <span style="color: red;">ID</span><span style="color: blue;">="DescriptionLabel"</span> <span style="color: red;">runat</span><span style="color: blue;">="server"</span> <span style="color: red;">Text</span><span style="color: blue;">='</span><span style="background: yellow; mso-highlight: yellow;">&lt;%</span># Bind("Description") <span style="background: yellow; mso-highlight: yellow;">%&gt;</span><span style="color: blue;">'&gt;&lt;/</span><span style="color: maroon;">asp</span><span style="color: blue;">:</span><span style="color: maroon;">Label</span><span style="color: blue;">&gt;&lt;</span><span style="color: maroon;">br</span> <span style="color: blue;">/&gt;</span></span></p> <p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: left; mso-layout-grid-align: none;" align="left"><span style="font-size: 9pt; font-family: 新宋体; mso-hansi-font-family: 'Times New Roman'; mso-font-kerning: 0pt; mso-no-proof: yes;" lang="EN-US"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="color: blue;">&lt;/</span><span style="color: maroon;">ItemTemplate</span><span style="color: blue;">&gt;</span></span></p> <p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: left; mso-layout-grid-align: none;" align="left"><span style="font-size: 9pt; font-family: 新宋体; mso-hansi-font-family: 'Times New Roman'; mso-font-kerning: 0pt; mso-no-proof: yes;" lang="EN-US"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="color: blue;">&lt;/</span><span style="color: maroon;">asp</span><span style="color: blue;">:</span><span style="color: maroon;">FormView</span><span style="color: blue;">&gt;</span></span></p> <p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: left; mso-layout-grid-align: none;" align="left"><span style="font-size: 9pt; font-family: 新宋体; mso-hansi-font-family: 'Times New Roman'; mso-font-kerning: 0pt; mso-no-proof: yes;" lang="EN-US"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp; </span><span style="color: blue;">&lt;/</span><span style="color: maroon;">div</span><span style="color: blue;">&gt;</span></span></p> <p class="MsoNormal" style="margin: 0cm 0cm 0pt;"><span style="font-size: 9pt; font-family: 新宋体; mso-hansi-font-family: 'Times New Roman'; mso-font-kerning: 0pt; mso-no-proof: yes;" lang="EN-US"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="color: blue;">&lt;</span><span style="color: maroon;">asp</span><span style="color: blue;">:</span><span style="color: maroon;">Button</span> <span style="color: red;">ID</span><span style="color: blue;">="Button1"</span> <span style="color: red;">runat</span><span style="color: blue;">="server"</span> <span style="color: red;">OnClick</span><span style="color: blue;">="Button1_Click"</span> <span style="color: red;">Text</span><span style="color: blue;">="</span></span><span style="font-size: 9pt; color: blue; font-family: 新宋体; mso-hansi-font-family: 'Times New Roman'; mso-font-kerning: 0pt; mso-no-proof: yes;">更改成编辑状态<span lang="EN-US">"</span></span><span style="font-size: 9pt; font-family: 新宋体; mso-hansi-font-family: 'Times New Roman'; mso-font-kerning: 0pt; mso-no-proof: yes;" lang="EN-US"> <span style="color: blue;">/&gt;</span></span></p> <p class="MsoNormal" style="margin: 0cm 0cm 0pt;"><span style="font-size: 9pt; color: blue; font-family: 新宋体; mso-hansi-font-family: 'Times New Roman'; mso-font-kerning: 0pt; mso-no-proof: yes;">后台代码:<span lang="EN-US"></span></span></p> <p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: left; mso-layout-grid-align: none;" align="left"><span style="font-size: 9pt; color: blue; font-family: 新宋体; mso-hansi-font-family: 'Times New Roman'; mso-font-kerning: 0pt; mso-no-proof: yes;" lang="EN-US">public</span><span style="font-size: 9pt; font-family: 新宋体; mso-hansi-font-family: 'Times New Roman'; mso-font-kerning: 0pt; mso-no-proof: yes;" lang="EN-US"> <span style="color: blue;">class</span> <span style="color: teal;">Category</span></span></p> <p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: left; mso-layout-grid-align: none;" align="left"><span style="font-size: 9pt; font-family: 新宋体; mso-hansi-font-family: 'Times New Roman'; mso-font-kerning: 0pt; mso-no-proof: yes;" lang="EN-US">{</span></p> <p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: left; mso-layout-grid-align: none;" align="left"><span style="font-size: 9pt; font-family: 新宋体; mso-hansi-font-family: 'Times New Roman'; mso-font-kerning: 0pt; mso-no-proof: yes;" lang="EN-US"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp; </span><span style="color: blue;">string</span> _categoryID = <span style="color: blue;">string</span>.Empty;</span></p> <p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: left; mso-layout-grid-align: none;" align="left"><span style="font-size: 9pt; font-family: 新宋体; mso-hansi-font-family: 'Times New Roman'; mso-font-kerning: 0pt; mso-no-proof: yes;" lang="EN-US">&nbsp;</span></p> <p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: left; mso-layout-grid-align: none;" align="left"><span style="font-size: 9pt; font-family: 新宋体; mso-hansi-font-family: 'Times New Roman'; mso-font-kerning: 0pt; mso-no-proof: yes;" lang="EN-US"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp; </span><span style="color: blue;">public</span> <span style="color: blue;">string</span> CategoryID</span></p> <p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: left; mso-layout-grid-align: none;" align="left"><span style="font-size: 9pt; font-family: 新宋体; mso-hansi-font-family: 'Times New Roman'; mso-font-kerning: 0pt; mso-no-proof: yes;" lang="EN-US"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp; </span>{</span></p> <p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: left; mso-layout-grid-align: none;" align="left"><span style="font-size: 9pt; font-family: 新宋体; mso-hansi-font-family: 'Times New Roman'; mso-font-kerning: 0pt; mso-no-proof: yes;" lang="EN-US"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="color: blue;">get</span> { <span style="color: blue;">return</span> _categoryID; }</span></p> <p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: left; mso-layout-grid-align: none;" align="left"><span style="font-size: 9pt; font-family: 新宋体; mso-hansi-font-family: 'Times New Roman'; mso-font-kerning: 0pt; mso-no-proof: yes;" lang="EN-US"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="color: blue;">set</span> { _categoryID = <span style="color: blue;">value</span>; }</span></p> <p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: left; mso-layout-grid-align: none;" align="left"><span style="font-size: 9pt; font-family: 新宋体; mso-hansi-font-family: 'Times New Roman'; mso-font-kerning: 0pt; mso-no-proof: yes;" lang="EN-US"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp; </span>}</span></p> <p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: left; mso-layout-grid-align: none;" align="left"><span style="font-size: 9pt; font-family: 新宋体; mso-hansi-font-family: 'Times New Roman'; mso-font-kerning: 0pt; mso-no-proof: yes;" lang="EN-US"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp; </span><span style="color: blue;">string</span> _categoryName = <span style="color: blue;">string</span>.Empty;</span></p> <p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: left; mso-layout-grid-align: none;" align="left"><span style="font-size: 9pt; font-family: 新宋体; mso-hansi-font-family: 'Times New Roman'; mso-font-kerning: 0pt; mso-no-proof: yes;" lang="EN-US">&nbsp;</span></p> <p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: left; mso-layout-grid-align: none;" align="left"><span style="font-size: 9pt; font-family: 新宋体; mso-hansi-font-family: 'Times New Roman'; mso-font-kerning: 0pt; mso-no-proof: yes;" lang="EN-US"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp; </span><span style="color: blue;">public</span> <span style="color: blue;">string</span> CategoryName</span></p> <p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: left; mso-layout-grid-align: none;" align="left"><span style="font-size: 9pt; font-family: 新宋体; mso-hansi-font-family: 'Times New Roman'; mso-font-kerning: 0pt; mso-no-proof: yes;" lang="EN-US"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp; </span>{</span></p> <p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: left; mso-layout-grid-align: none;" align="left"><span style="font-size: 9pt; font-family: 新宋体; mso-hansi-font-family: 'Times New Roman'; mso-font-kerning: 0pt; mso-no-proof: yes;" lang="EN-US"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="color: blue;">get</span> { <span style="color: blue;">return</span> _categoryName; }</span></p> <p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: left; mso-layout-grid-align: none;" align="left"><span style="font-size: 9pt; font-family: 新宋体; mso-hansi-font-family: 'Times New Roman'; mso-font-kerning: 0pt; mso-no-proof: yes;" lang="EN-US"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="color: blue;">set</span> { _categoryName = <span style="color: blue;">value</span>; }</span></p> <p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: left; mso-layout-grid-align: none;" align="left"><span style="font-size: 9pt; font-family: 新宋体; mso-hansi-font-family: 'Times New Roman'; mso-font-kerning: 0pt; mso-no-proof: yes;" lang="EN-US"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp; </span>}</span></p> <p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: left; mso-layout-grid-align: none;" align="left"><span style="font-size: 9pt; font-family: 新宋体; mso-hansi-font-family: 'Times New Roman'; mso-font-kerning: 0pt; mso-no-proof: yes;" lang="EN-US"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp; </span><span style="color: blue;">string</span> _description = <span style="color: blue;">string</span>.Empty;</span></p> <p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: left; mso-layout-grid-align: none;" align="left"><span style="font-size: 9pt; font-family: 新宋体; mso-hansi-font-family: 'Times New Roman'; mso-font-kerning: 0pt; mso-no-proof: yes;" lang="EN-US">&nbsp;</span></p> <p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: left; mso-layout-grid-align: none;" align="left"><span style="font-size: 9pt; font-family: 新宋体; mso-hansi-font-family: 'Times New Roman'; mso-font-kerning: 0pt; mso-no-proof: yes;" lang="EN-US"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp; </span><span style="color: blue;">public</span> <span style="color: blue;">string</span> Description</span></p> <p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: left; mso-layout-grid-align: none;" align="left"><span style="font-size: 9pt; font-family: 新宋体; mso-hansi-font-family: 'Times New Roman'; mso-font-kerning: 0pt; mso-no-proof: yes;" lang="EN-US"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp; </span>{</span></p> <p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: left; mso-layout-grid-align: none;" align="left"><span style="font-size: 9pt; font-family: 新宋体; mso-hansi-font-family: 'Times New Roman'; mso-font-kerning: 0pt; mso-no-proof: yes;" lang="EN-US"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="color: blue;">get</span> { <span style="color: blue;">return</span> _description; }</span></p> <p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: left; mso-layout-grid-align: none;" align="left"><span style="font-size: 9pt; font-family: 新宋体; mso-hansi-font-family: 'Times New Roman'; mso-font-kerning: 0pt; mso-no-proof: yes;" lang="EN-US"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="color: blue;">set</span> { _description = <span style="color: blue;">value</span>; }</span></p> <p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: left; mso-layout-grid-align: none;" align="left"><span style="font-size: 9pt; font-family: 新宋体; mso-hansi-font-family: 'Times New Roman'; mso-font-kerning: 0pt; mso-no-proof: yes;" lang="EN-US"><span style="mso-spacerun: yes;">&nbsp; </span><span style="mso-spacerun: yes;">&nbsp;&nbsp;</span>}</span></p> <p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: left; mso-layout-grid-align: none;" align="left"><span style="font-size: 9pt; font-family: 新宋体; mso-hansi-font-family: 'Times New Roman'; mso-font-kerning: 0pt; mso-no-proof: yes;" lang="EN-US"><span style="mso-tab-count: 1;">&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="color: blue;">public</span> Category()</span></p> <p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: left; mso-layout-grid-align: none;" align="left"><span style="font-size: 9pt; font-family: 新宋体; mso-hansi-font-family: 'Times New Roman'; mso-font-kerning: 0pt; mso-no-proof: yes;" lang="EN-US"><span style="mso-tab-count: 1;">&nbsp;&nbsp;&nbsp;&nbsp; </span>{<span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></span></p> <p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: left; mso-layout-grid-align: none;" align="left"><span style="font-size: 9pt; font-family: 新宋体; mso-hansi-font-family: 'Times New Roman'; mso-font-kerning: 0pt; mso-no-proof: yes;" lang="EN-US"><span style="mso-tab-count: 1;">&nbsp;&nbsp;&nbsp;&nbsp; </span>}</span></p> <p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: left; mso-layout-grid-align: none;" align="left"><span style="font-size: 9pt; font-family: 新宋体; mso-hansi-font-family: 'Times New Roman'; mso-font-kerning: 0pt; mso-no-proof: yes;" lang="EN-US"><span style="mso-spacerun: yes;">&nbsp;&nbsp; </span></span></p> <p class="MsoNormal" style="margin: 0cm 0cm 0pt;"><span style="font-size: 9pt; font-family: 新宋体; mso-hansi-font-family: 'Times New Roman'; mso-font-kerning: 0pt; mso-no-proof: yes;" lang="EN-US">}</span></p> <p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: left; mso-layout-grid-align: none;" align="left"><span style="font-size: 9pt; font-family: 新宋体; mso-hansi-font-family: 'Times New Roman'; mso-font-kerning: 0pt; mso-no-proof: yes;" lang="EN-US"><span style="mso-spacerun: yes;">&nbsp;&nbsp; </span><span style="color: blue;">protected</span> <span style="color: blue;">void</span> Page_Load(<span style="color: blue;">object</span> sender, <span style="color: teal;">EventArgs</span> e)</span></p> <p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: left; mso-layout-grid-align: none;" align="left"><span style="font-size: 9pt; font-family: 新宋体; mso-hansi-font-family: 'Times New Roman'; mso-font-kerning: 0pt; mso-no-proof: yes;" lang="EN-US"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp; </span>{</span></p> <p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: left; mso-layout-grid-align: none;" align="left"><span style="font-size: 9pt; font-family: 新宋体; mso-hansi-font-family: 'Times New Roman'; mso-font-kerning: 0pt; mso-no-proof: yes;" lang="EN-US"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="color: green;">//if (!IsPostBack)</span></span></p> <p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: left; mso-layout-grid-align: none;" align="left"><span style="font-size: 9pt; font-family: 新宋体; mso-hansi-font-family: 'Times New Roman'; mso-font-kerning: 0pt; mso-no-proof: yes;" lang="EN-US"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="color: green;">//{</span></span></p> <p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: left; mso-layout-grid-align: none;" align="left"><span style="font-size: 9pt; font-family: 新宋体; mso-hansi-font-family: 'Times New Roman'; mso-font-kerning: 0pt; mso-no-proof: yes;" lang="EN-US"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="color: blue;">this</span>.FormView1.DataSource = GetDataSourse();</span></p> <p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: left; mso-layout-grid-align: none;" align="left"><span style="font-size: 9pt; font-family: 新宋体; mso-hansi-font-family: 'Times New Roman'; mso-font-kerning: 0pt; mso-no-proof: yes;" lang="EN-US"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="color: blue;">this</span>.FormView1.DataBind();</span></p> <p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: left; mso-layout-grid-align: none;" align="left"><span style="font-size: 9pt; font-family: 新宋体; mso-hansi-font-family: 'Times New Roman'; mso-font-kerning: 0pt; mso-no-proof: yes;" lang="EN-US"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="color: green;">// }</span></span></p> <p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: left; mso-layout-grid-align: none;" align="left"><span style="font-size: 9pt; font-family: 新宋体; mso-hansi-font-family: 'Times New Roman'; mso-font-kerning: 0pt; mso-no-proof: yes;" lang="EN-US"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp; </span>}</span></p> <p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: left; mso-layout-grid-align: none;" align="left"><span style="font-size: 9pt; font-family: 新宋体; mso-hansi-font-family: 'Times New Roman'; mso-font-kerning: 0pt; mso-no-proof: yes;" lang="EN-US"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp; </span><span style="color: blue;">protected</span> <span style="color: blue;">void</span> Button1_Click(<span style="color: blue;">object</span> sender, <span style="color: teal;">EventArgs</span> e)</span></p> <p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: left; mso-layout-grid-align: none;" align="left"><span style="font-size: 9pt; font-family: 新宋体; mso-hansi-font-family: 'Times New Roman'; mso-font-kerning: 0pt; mso-no-proof: yes;" lang="EN-US"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp; </span>{</span></p> <p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: left; mso-layout-grid-align: none;" align="left"><span style="font-size: 9pt; font-family: 新宋体; mso-hansi-font-family: 'Times New Roman'; mso-font-kerning: 0pt; mso-no-proof: yes;" lang="EN-US"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="color: blue;">this</span>.FormView1.ChangeMode(<span style="color: teal;">FormViewMode</span>.Edit);</span></p> <p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: left; mso-layout-grid-align: none;" align="left"><span style="font-size: 9pt; font-family: 新宋体; mso-hansi-font-family: 'Times New Roman'; mso-font-kerning: 0pt; mso-no-proof: yes;" lang="EN-US"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp; </span>}</span></p> <p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: left; mso-layout-grid-align: none;" align="left"><span style="font-size: 9pt; font-family: 新宋体; mso-hansi-font-family: 'Times New Roman'; mso-font-kerning: 0pt; mso-no-proof: yes;" lang="EN-US"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp; </span><span style="color: blue;">protected</span> <span style="color: blue;">void</span> FormView1_ItemCommand(<span style="color: blue;">object</span> sender, <span style="color: teal;">FormViewCommandEventArgs</span> e)</span></p> <p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: left; mso-layout-grid-align: none;" align="left"><span style="font-size: 9pt; font-family: 新宋体; mso-hansi-font-family: 'Times New Roman'; mso-font-kerning: 0pt; mso-no-proof: yes;" lang="EN-US"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp; </span>{</span></p> <p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: left; mso-layout-grid-align: none;" align="left"><span style="font-size: 9pt; font-family: 新宋体; mso-hansi-font-family: 'Times New Roman'; mso-font-kerning: 0pt; mso-no-proof: yes;" lang="EN-US"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>Response.Write(<span style="color: maroon;">"FormView1_ItemCommand"</span>);</span></p> <p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: left; mso-layout-grid-align: none;" align="left"><span style="font-size: 9pt; font-family: 新宋体; mso-hansi-font-family: 'Times New Roman'; mso-font-kerning: 0pt; mso-no-proof: yes;" lang="EN-US"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp; </span>}</span></p> <p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: left; mso-layout-grid-align: none;" align="left"><span style="font-size: 9pt; font-family: 新宋体; mso-hansi-font-family: 'Times New Roman'; mso-font-kerning: 0pt; mso-no-proof: yes;" lang="EN-US"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp; </span><span style="color: blue;">protected</span> <span style="color: blue;">void</span> FormView1_ItemUpdating(<span style="color: blue;">object</span> sender, <span style="color: teal;">FormViewUpdateEventArgs</span> e)</span></p> <p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: left; mso-layout-grid-align: none;" align="left"><span style="font-size: 9pt; font-family: 新宋体; mso-hansi-font-family: 'Times New Roman'; mso-font-kerning: 0pt; mso-no-proof: yes;" lang="EN-US"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp; </span>{</span></p> <p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: left; mso-layout-grid-align: none;" align="left"><span style="font-size: 9pt; font-family: 新宋体; mso-hansi-font-family: 'Times New Roman'; mso-font-kerning: 0pt; mso-no-proof: yes;" lang="EN-US"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>Response.Write(<span style="color: maroon;">"FormView1_ItemUpdating"</span>);</span></p> <p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: left; mso-layout-grid-align: none;" align="left"><span style="font-size: 9pt; font-family: 新宋体; mso-hansi-font-family: 'Times New Roman'; mso-font-kerning: 0pt; mso-no-proof: yes;" lang="EN-US"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp; </span>}</span></p> <p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: left; mso-layout-grid-align: none;" align="left"><span style="font-size: 9pt; font-family: 新宋体; mso-hansi-font-family: 'Times New Roman'; mso-font-kerning: 0pt; mso-no-proof: yes;" lang="EN-US">&nbsp;</span></p> <p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: left; mso-layout-grid-align: none;" align="left"><span style="font-size: 9pt; font-family: 新宋体; mso-hansi-font-family: 'Times New Roman'; mso-font-kerning: 0pt; mso-no-proof: yes;" lang="EN-US"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp; </span><span style="color: blue;">private</span> <span style="color: teal;">IList</span>&lt;<span style="color: teal;">Category</span>&gt; GetDataSourse()</span></p> <p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: left; mso-layout-grid-align: none;" align="left"><span style="font-size: 9pt; font-family: 新宋体; mso-hansi-font-family: 'Times New Roman'; mso-font-kerning: 0pt; mso-no-proof: yes;" lang="EN-US"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp; </span>{</span></p> <p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: left; mso-layout-grid-align: none;" align="left"><span style="font-size: 9pt; font-family: 新宋体; mso-hansi-font-family: 'Times New Roman'; mso-font-kerning: 0pt; mso-no-proof: yes;" lang="EN-US"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="color: teal;">IList</span>&lt;<span style="color: teal;">Category</span>&gt; data = <span style="color: blue;">new</span> <span style="color: teal;">List</span>&lt;<span style="color: teal;">Category</span>&gt;();</span></p> <p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: left; mso-layout-grid-align: none;" align="left"><span style="font-size: 9pt; font-family: 新宋体; mso-hansi-font-family: 'Times New Roman'; mso-font-kerning: 0pt; mso-no-proof: yes;" lang="EN-US"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="color: teal;">Category</span> ct = <span style="color: blue;">new</span> <span style="color: teal;">Category</span>();</span></p> <p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: left; mso-layout-grid-align: none;" align="left"><span style="font-size: 9pt; font-family: 新宋体; mso-hansi-font-family: 'Times New Roman'; mso-font-kerning: 0pt; mso-no-proof: yes;" lang="EN-US"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>ct.CategoryID = <span style="color: maroon;">"1"</span>;</span></p> <p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: left; mso-layout-grid-align: none;" align="left"><span style="font-size: 9pt; font-family: 新宋体; mso-hansi-font-family: 'Times New Roman'; mso-font-kerning: 0pt; mso-no-proof: yes;" lang="EN-US"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>ct.CategoryName = <span style="color: maroon;">"PC"</span>;</span></p> <p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: left; mso-layout-grid-align: none;" align="left"><span style="font-size: 9pt; font-family: 新宋体; mso-hansi-font-family: 'Times New Roman'; mso-font-kerning: 0pt; mso-no-proof: yes;" lang="EN-US"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>ct.Description = <span style="color: maroon;">"</span></span><span style="font-size: 9pt; color: maroon; font-family: 新宋体; mso-hansi-font-family: 'Times New Roman'; mso-font-kerning: 0pt; mso-no-proof: yes;">电脑<span lang="EN-US">"</span></span><span style="font-size: 9pt; font-family: 新宋体; mso-hansi-font-family: 'Times New Roman'; mso-font-kerning: 0pt; mso-no-proof: yes;" lang="EN-US">;</span></p> <p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: left; mso-layout-grid-align: none;" align="left"><span style="font-size: 9pt; font-family: 新宋体; mso-hansi-font-family: 'Times New Roman'; mso-font-kerning: 0pt; mso-no-proof: yes;" lang="EN-US"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>data.Add(ct);</span></p> <p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: left; mso-layout-grid-align: none;" align="left"><span style="font-size: 9pt; font-family: 新宋体; mso-hansi-font-family: 'Times New Roman'; mso-font-kerning: 0pt; mso-no-proof: yes;" lang="EN-US"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span><span style="color: blue;">return</span> data;</span></p> <p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: left; mso-layout-grid-align: none;" align="left"><span style="font-size: 9pt; font-family: 新宋体; mso-hansi-font-family: 'Times New Roman'; mso-font-kerning: 0pt; mso-no-proof: yes;" lang="EN-US"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp; </span>}</span></p> <p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: left; mso-layout-grid-align: none;" align="left"><span style="font-size: 9pt; font-family: 新宋体; mso-hansi-font-family: 'Times New Roman'; mso-font-kerning: 0pt; mso-no-proof: yes;" lang="EN-US"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp; </span><span style="color: blue;">protected</span> <span style="color: blue;">void</span> FormView1_ItemUpdated(<span style="color: blue;">object</span> sender, <span style="color: teal;">FormViewUpdatedEventArgs</span> e)</span></p> <p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: left; mso-layout-grid-align: none;" align="left"><span style="font-size: 9pt; font-family: 新宋体; mso-hansi-font-family: 'Times New Roman'; mso-font-kerning: 0pt; mso-no-proof: yes;" lang="EN-US"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp; </span>{</span></p> <p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: left; mso-layout-grid-align: none;" align="left"><span style="font-size: 9pt; font-family: 新宋体; mso-hansi-font-family: 'Times New Roman'; mso-font-kerning: 0pt; mso-no-proof: yes;" lang="EN-US"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>Response.Write(<span style="color: maroon;">"FormView1_ItemUpdated"</span>);</span></p> <p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: left; mso-layout-grid-align: none;" align="left"><span style="font-size: 9pt; font-family: 新宋体; mso-hansi-font-family: 'Times New Roman'; mso-font-kerning: 0pt; mso-no-proof: yes;" lang="EN-US"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp; </span>}</span></p> <p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: left; mso-layout-grid-align: none;" align="left"><span style="font-size: 9pt; font-family: 新宋体; mso-hansi-font-family: 'Times New Roman'; mso-font-kerning: 0pt; mso-no-proof: yes;" lang="EN-US"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp; </span><span style="color: blue;">protected</span> <span style="color: blue;">void</span> FormView1_ModeChanging(<span style="color: blue;">object</span> sender, <span style="color: teal;">FormViewModeEventArgs</span> e)</span></p> <p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: left; mso-layout-grid-align: none;" align="left"><span style="font-size: 9pt; font-family: 新宋体; mso-hansi-font-family: 'Times New Roman'; mso-font-kerning: 0pt; mso-no-proof: yes;" lang="EN-US"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp; </span>{</span></p> <p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-align: left; mso-layout-grid-align: none;" align="left"><span style="font-size: 9pt; font-family: 新宋体; mso-hansi-font-family: 'Times New Roman'; mso-font-kerning: 0pt; mso-no-proof: yes;" lang="EN-US"><span style="mso-spacerun: yes;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span>Response.Write(<span style="color: maroon;">"FormView1_ModeChanging"</span>);</span></p> <p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-indent: 18pt;"><span style="font-size: 9pt; font-family: 新宋体; mso-hansi-font-family: 'Times New Roman'; mso-font-kerning: 0pt; mso-no-proof: yes;" lang="EN-US">}</span></p> <p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-indent: 18pt;"><span style="font-size: 9pt; font-family: 新宋体; mso-hansi-font-family: 'Times New Roman'; mso-font-kerning: 0pt; mso-no-proof: yes;" lang="EN-US">&nbsp;</span></p> <p class="MsoNormal" style="margin: 0cm 0cm 0pt; text-indent: 18pt;"><span style="font-size: 9pt; font-family: 新宋体; mso-hansi-font-family: 'Times New Roman'; mso-font-kerning: 0pt; mso-no-proof: yes;">问题:<span lang="EN-US"></span></span></p> <p class="MsoNormal" style="margin: 0cm 0cm 0pt 58.5pt; text-indent: -31.5pt; mso-list: l0 level1 lfo1; tab-stops: list 58.5pt;"><span style="font-size: 9pt; font-family: 新宋体; mso-hansi-font-family: 'Times New Roman'; mso-font-kerning: 0pt; mso-no-proof: yes; mso-bidi-font-family: 新宋体;" lang="EN-US"><span style="mso-list: Ignore;">1.<span style="font: 7pt &quot;Times New Roman&quot;;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></span></span><span style="font-size: 9pt; font-family: 新宋体; mso-hansi-font-family: 'Times New Roman'; mso-font-kerning: 0pt; mso-no-proof: yes;">在编辑状态下同样是设置的<span lang="EN-US">CommandName</span>的<span lang="EN-US">Button </span>和<span lang="EN-US">LinkButton </span>如果没有加<span lang="EN-US">if(!IsPostBack)</span>判断,<span lang="EN-US">LinkButton</span>将会预期触发<span lang="EN-US">ItemCommand</span>,<span lang="EN-US">ItemUpdating</span>事件,而<span lang="EN-US">Button</span>不会。但在加有<span lang="EN-US">if(!IsPostBack)</span>的情况下。<span lang="EN-US">Button </span>与<span lang="EN-US">LinkButton</span>都会触发<span lang="EN-US">ItemCommand</span>,<span lang="EN-US">ItemUpdating</span>为什么?<span lang="EN-US"></span></span></p> <p class="MsoNormal" style="margin: 0cm 0cm 0pt 58.5pt; text-indent: -31.5pt; mso-list: l0 level1 lfo1; tab-stops: list 58.5pt;"><span style="font-size: 9pt; font-family: 新宋体; mso-hansi-font-family: 'Times New Roman'; mso-font-kerning: 0pt; mso-no-proof: yes; mso-bidi-font-family: 新宋体;" lang="EN-US"><span style="mso-list: Ignore;">2.<span style="font: 7pt &quot;Times New Roman&quot;;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></span></span><span style="font-size: 9pt; font-family: 新宋体; mso-hansi-font-family: 'Times New Roman'; mso-font-kerning: 0pt; mso-no-proof: yes;" lang="EN-US">ItemUpdated</span><span style="font-size: 9pt; font-family: 新宋体; mso-hansi-font-family: 'Times New Roman'; mso-font-kerning: 0pt; mso-no-proof: yes;">事件始终不被触发,为什么?<span lang="EN-US"></span></span></p> <p class="MsoNormal" style="margin: 0cm 0cm 0pt 58.5pt; text-indent: -31.5pt; mso-list: l0 level1 lfo1; tab-stops: list 58.5pt;"><span style="font-size: 9pt; font-family: 新宋体; mso-hansi-font-family: 'Times New Roman'; mso-font-kerning: 0pt; mso-no-proof: yes; mso-bidi-font-family: 新宋体;" lang="EN-US"><span style="mso-list: Ignore;">3.<span style="font: 7pt &quot;Times New Roman&quot;;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></span></span><span style="font-size: 9pt; font-family: 新宋体; mso-hansi-font-family: 'Times New Roman'; mso-font-kerning: 0pt; mso-no-proof: yes;">为什么每次是在两次点击&ldquo;<span style="color: blue;">更改成编辑状态&rdquo;按钮才能将<span lang="EN-US">FormView</span>改变成编辑状态。</span><span lang="EN-US"></span></span></p> <p class="MsoNormal" style="margin: 0cm 0cm 0pt 58.5pt; text-indent: -31.5pt; mso-list: l0 level1 lfo1; tab-stops: list 58.5pt;"><span style="font-size: 9pt; font-family: 新宋体; mso-hansi-font-family: 'Times New Roman'; mso-font-kerning: 0pt; mso-no-proof: yes; mso-bidi-font-family: 新宋体;" lang="EN-US"><span style="mso-list: Ignore;">4.<span style="font: 7pt &quot;Times New Roman&quot;;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></span></span><span style="font-size: 9pt; font-family: 新宋体; mso-hansi-font-family: 'Times New Roman'; mso-font-kerning: 0pt; mso-no-proof: yes;">为什么在使用<span lang="EN-US">DataSource</span>数据源的情况下<span lang="EN-US">ComandName</span>为<span lang="EN-US">Cancel</span>是按钮需要处理<span lang="EN-US">ModeChanging</span>事件,而在指定<span lang="EN-US">DataSourceID</span>是他会自动回到<span lang="EN-US">DefaultModel</span>状态。<span lang="EN-US"></span></span></p> <p class="MsoNormal" style="margin: 0cm 0cm 0pt 58.5pt; text-indent: -31.5pt; mso-list: l0 level1 lfo1; tab-stops: list 58.5pt;"><span style="font-size: 9pt; font-family: 新宋体; mso-hansi-font-family: 'Times New Roman'; mso-font-kerning: 0pt; mso-no-proof: yes; mso-bidi-font-family: 新宋体;" lang="EN-US"><span style="mso-list: Ignore;">5.<span style="font: 7pt &quot;Times New Roman&quot;;">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </span></span></span><span style="font-size: 9pt; font-family: 新宋体; mso-hansi-font-family: 'Times New Roman'; mso-font-kerning: 0pt; mso-no-proof: yes;">我如何能在更新和取消后回到<span lang="EN-US">DefaultModel</span>状态?<span lang="EN-US"></span></span></p>
明轩的主页 明轩 | 初学一级 | 园豆:170
提问于:2008-12-25 20:01
< >
分享
其他回答(1)
0

前两个没注意过~

3.     点击后应该重新绑定。因为Editing的时候GridView已经生成完了。如果不重新执行绑定就会按已经生成的状态去显示,下次再提交的时候就显示成编辑状态了(不用两次都点更改成编辑状态,点了一次更改成编辑状态,第二次随便一个PostBack事件都会有这样的效果)

4.     不光Cancel所有RowComand事件+分页事件都是,在这些事件后都要重新绑定数据源。指定DataSourceID的时候.net知道怎么重新绑定数据源、而使用DataSource的时候.net不知道怎么绑定数据源所以你得亲自处理。

5.     RowUpdating和RowCancelingEdit后  EditIndex=-1;再绑定

 

BB_Coder | 园豆:895 (小虾三级) | 2008-12-26 08:34
0

你可以参考一下页面的生命周期。http://blog.csdn.net/Vigorcsdn/archive/2006/01/07/572552.aspx

长风一剑 | 园豆:29 (初学一级) | 2008-12-26 10:10
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册