源错误:
行 19: {
行 20: int id = Convert.ToInt32(GVContype.DataKeys[GVContype.EditIndex][0]);
行 21: string Title =Convert.ToString (GVContype.DataKeys[GVContype.EditIndex][1]);
行 22: int type = Convert.ToInt32(GVContype.DataKeys[GVContype.EditIndex][2]);
行 23: string intro = ((TextBox)this.GVContype.DataKeys[GVContype.EditIndex][3]).ToString();
源文件: e:\工作\Web\ComContentType.aspx.cs 行: 21
网上找了很多办法都不行 到底要怎么弄啊~~在线等
行 19: {
行 20: int id = Convert.ToInt32(GVContype.DataKeys[GVContype.EditIndex][0]);
行 21: string Title =Convert.ToString (GVContype.DataKeys[GVContype.EditIndex][1]);
行 22: int type = Convert.ToInt32(GVContype.DataKeys[GVContype.EditIndex][2]);
行 23: string intro = ((TextBox)this.GVContype.DataKeys[GVContype.EditIndex][3]).ToString();
源文件: e:\工作\Web\ComContentType.aspx.cs 行: 21
网上找了很多办法都不行 到底要怎么弄啊~~在线等
你就说你要干什么吧??然后把你的前台代码贴出来看下!~·
int id = Convert.ToInt32(GVContype.DataKeys[GVContype.EditIndex][0]);
string Title =Convert.ToString (GVContype.DataKeys[GVContype.EditIndex][1]);
int type = Convert.ToInt32(GVContype.DataKeys[GVContype.EditIndex][2]);
string intro = ((TextBox)this.GVContype.DataKeys[GVContype.EditIndex][3]).ToString();
int hits = Convert.ToInt32(GVContype.DataKeys[GVContype.EditIndex][4]);
DateTime checkintime = Convert.ToDateTime((TextBox)this.GVContype.DataKeys[GVContype.EditIndex][5]);
int sortid = Convert.ToInt32(GVContype.DataKeys[GVContype.EditIndex][6]);
int staue = Convert.ToInt32(GVContype.DataKeys[GVContype.EditIndex][7]); ComContentType_BC.update_Contenttype(id, Title, type, intro, hits, checkintime, sortid, staue);
把前台代码拿出来看看!~~
然后你这个GridView你要怎么修改??
DataSourceID="SqlDataSource2" OnRowUpdating="GVContype_RowUpdating" Width="1096px">
<Columns>
<asp:BoundField DataField="ComContentTypeID" HeaderText="ComContentTypeID" InsertVisible="False"
ReadOnly="True" SortExpression="ComContentTypeID" />
<asp:BoundField DataField="Title" HeaderText="Title" SortExpression="Title" />
<asp:BoundField DataField="Type" HeaderText="Type" SortExpression="Type" />
<asp:BoundField DataField="Intro" HeaderText="Intro" SortExpression="Intro" />
<asp:BoundField DataField="Hits" HeaderText="Hits" SortExpression="Hits" />
<asp:BoundField DataField="CheckInTime" HeaderText="CheckInTime" SortExpression="CheckInTime" />
<asp:BoundField DataField="SortID" HeaderText="SortID" SortExpression="SortID" />
<asp:BoundField DataField="Status" HeaderText="Status" SortExpression="Status" />
<asp:CommandField ShowEditButton="True" />
<asp:CommandField ShowDeleteButton="True" />
</Columns>
</asp:GridView>
<asp:SqlDataSource ID="SqlDataSource2" runat="server" ConnectionString="<%$ ConnectionStrings:19ding_cnConnectionString4 %>"
SelectCommand="SELECT * FROM [ComContentType]"></asp:SqlDataSource>直接在列表里点修改,可以对数据进行操作。
{
int ID = Convert.ToInt32(GridView1.DataKeys[e.RowIndex].Value.ToString());
string Title = ((TextBox)(GVContype.Rows[e.RowIndex].Cells[1].Controls[0])).Text.ToString().Trim();
int type = Convert.ToInt32(((TextBox)(GVContype.Rows[e.RowIndex].Cells[2].Controls[0])).Text.ToString().Trim());
string intro = ((TextBox)(GVContype.Rows[e.RowIndex].Cells[3].Controls[0])).Text.ToString().Trim();
int hits = Convert.ToInt32(((TextBox)(GVContype.Rows[e.RowIndex].Cells[4].Controls[0])).Text.ToString().Trim());
//后略,照着前面的写
ComContentType_BC.update_Contenttype(id, Title, type, intro, hits, checkintime, sortid, staue);
GridView1.EditIndex = -1;
bind(); //数据绑定函数
} protected void GridView1_RowEditing(object sender, GridViewEditEventArgs e)
{
GridView1.EditIndex = e.NewEditIndex;
bind();
} protected void GridView1_RowCancelingEdit(object sender, GridViewCancelEditEventArgs e)
{
GridView1.EditIndex = -1;
bind();
} protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e)
{
string sqlStr = "delete from Employee where ID=" + Convert.ToInt32(GridView1.DataKeys[e.RowIndex].Value) + "";
Common.ExecuteSql(sqlStr);
bind();
}
这就要看你更新后有没有成功的写如数据库了。。
写入数据库成功后又要看你有没有对这个GridView进行再次绑定了!~~