开发者

ASP.Net Gridview Update event

I have created a custom event to handle how the data should be updated in my gridview. The problem is, it is not firing. I have used debug mode and not even the breakpoint comes into effect when I click the update button.

Here is the event handler I have written:

protected void DocView_RowUpdating(object sender, GridViewUpdateEventArgs e)
{
    var rw = DocView.Rows[e.RowIndex] ;
    var Doc = (TextBox)rw.FindControl("DocTB");
    var Num = (TextBox)rw.FindControl("NumberTB");
    var Iss = (TextBox)rw.FindControl("IssuedTB");
    var Exp = (TextBox)rw.FindCon开发者_如何学Pythontrol("ExpiryTB");
    var Stat = (TextBox)rw.FindControl("StatusTB");


    var con = new LinqDBDataContext();
    var doc = (from i in con.Documents
              where i.DocumentID == e.RowIndex
              select i).Single();
    doc.DocumentType = Doc.Text;
    doc.Number = Num.Text;
    doc.Issued = DateTime.Parse(Iss.Text);
    doc.Expiry = DateTime.Parse(Exp.Text);
    doc.Status = Stat.Text;
    con.SubmitChanges();

    DocView.EditIndex = -1;

}

The event just will not fire!


Sounds like your missing some plumbing!

Are you using some type of development kit such as Visual Studio?

Usually these kit's will do most of the plumbing for you. Be aware, there is a little more to wiring up the event handler than just providing the following function:

protected void DocView_RowUpdating(object sender, GridViewUpdateEventArgs e)

If your in Visual Studio, try clicking the lightning bolt on the GridView's property page to take a look at the event handlers for it.

Then double click the RowUpdating Event and try pasting your code in there to see if you can get your break point to fire!

Good luck.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜