新手求助,为什么绑定数据后无法编辑……
为什么我一点编辑,就出现javascript错误,提示对象不支持此方法或属性。
前台:
<asp:DataGrid ID= "MyDataGrid " runat= "server " Width= "700 " BackColor= "#ECDCF2 " BorderColor= "Black "
ShowFooter= "false " CellPadding= "3 " CellSpacing= "0 " Font-Names= "宋体 " Font-Size= "10pt "
HeaderStyle-BackColor= "#C59FD2 " OnEditCommand= "MyDataGrid_Edit "
OnCancelCommand= "MyDataGrid_Cancel " OnUpdateCommand= "MyDataGrid_Update " DataKeyField= "emp_no ">
<Columns>
<asp:EditCommandColumn EditText= "编辑 " CancelText= "取消 " UpdateText= "更新 " ItemStyle-Wrap= "false "> </asp:EditCommandColumn>
</Columns>
</asp:DataGrid>
后台:
public void MyDataGrid_Edit(Object sender, DataGridCommandEventArgs e)
{
MyDataGrid.EditItemIndex = (int)e.Item.ItemIndex;
bind();
}
public void MyDataGrid_Cancel(Object sender, DataGridCommandEventArgs e)
{
MyDataGrid.EditItemIndex = -1;
bind();
}
public void MyDataGrid_Update(Object sender, DataGridCommandEventArgs e)
{
String updateCmd = "UPDATE holiday SET holi_hour = @hour, the_from = @from, the_to = @to, used = @used where emp_no = @emp_no ";
SqlCommand myCommand = new SqlCommand(updateCmd, myConnection);
……
}
[解决办法]
sf
[解决办法]
这里应该是这样的吧?
<Columns>
<asp:EditCommandColumn ButtonType= "LinkButton " UpdateText= "更新 " CancelText= "取消 " EditText= "编辑 "> </asp:EditCommandColumn>
</Columns>
你的HTML代码里怎么没有 EditCommandColumn ButtonType= "LinkButton "这句?
[解决办法]
你用的03还是05?
[解决办法]
你要用的05 那写的没错
要用的是03 就少了我上面说的那句
其他代码没觉得有什么错误
[解决办法]
重新建一页 重新写一下