问题描述
HTML代码:<bodyMS_POSITIONING="GridLayout"><formid="Form1"method="post"runat="server"><asp:DataGridid="DataGrid1"style="Z-INDEX:101;LEFT:284px;POSITION:absolute;TOP:136px"runat="server"BorderColor="#E7E7FF"BorderStyle="None"BorderWidth="1px"BackColor="White"CellPadding="3"GridLines="Horizontal"AutoGenerateColumns="False"Width="535px"Height="242px"><SelectedItemStyleFont-Bold="True"ForeColor="#F7F7F7"BackColor="#738A9C"></SelectedItemStyle><AlternatingItemStyleBackColor="#F7F7F7"></AlternatingItemStyle><ItemStyleForeColor="#4A3C8C"BackColor="#E7E7FF"></ItemStyle><HeaderStyleFont-Bold="True"ForeColor="#F7F7F7"BackColor="#4A3C8C"></HeaderStyle><FooterStyleForeColor="#4A3C8C"BackColor="#B5C7DE"></FooterStyle><Columns><asp:BoundColumnDataField="颜色"ReadOnly="True"></asp:BoundColumn><asp:BoundColumnDataField="80"HeaderText="80"></asp:BoundColumn><asp:BoundColumnDataField="90"HeaderText="90"></asp:BoundColumn><asp:BoundColumnDataField="100"HeaderText="100"></asp:BoundColumn></Columns><PagerStyleHorizontalAlign="Right"ForeColor="#4A3C8C"BackColor="#E7E7FF"Mode="NumericPages"></PagerStyle></asp:DataGrid></form></body>CS代码:privatevoidPage_Load(objectsender,System.EventArgse){if(!this.IsPostBack){this.BintDataGrid();}//在此处放置用户代码以初始化页面}publicvoidBintDataGrid(){SqlConnectioncon=newSqlConnection("Server=.;database=aico;uid=sa;pwd=aico");con.Open();SqlCommandcmd=newSqlCommand("select*fromtest",con);SqlDataAdaptersda=newSqlDataAdapter();sda.SelectCommand=cmd;DataSetds=newDataSet();sda.Fill(ds,"test");this.DataGrid1.DataSource=ds;this.DataBind();}
解决方案
解决方案二:
DataGrid有个EditIndex属性可以设置
解决方案三:
设置DataGrid.EditIndex
解决方案四:
this.DataGrid1.DataSource=ds;this.DataGrid1.EditIndex=**;this.DataGrid1.DataBind();
解决方案五:
请问怎样可以将所有行都处于编辑状态啊?this.DataGrid1.EditItemIndex=???????该怎样填啊?
解决方案六:
在生成行事件里,Datarowbound里,循环行,然后分别设置不就可以了么.
解决方案七:
具体应该怎样做啊?
解决方案八:
网上查吧,我把思路说清楚了.
解决方案九:
在DataBound事件中,循环将rows的INDEX赋给EditIndex.