开发者

Accessing ItemTemplate from codebehind

I have a GView and I am populating rows from code behind. However, in the RowUpdating event I want to access the changes done by the user and store that change into a string. Here is my code:

 protected void 开发者_如何学编程gvShowComm_RowUpdating(object sender, GridViewUpdateEventArgs e)
    {
        System.Web.UI.WebControls.TextBox myBox = gvShowComm.Rows[e.RowIndex].FindControl("PlanName") as System.Web.UI.WebControls.TextBox;
        string s = myBox.Text;
        gvShowComm.DataBind();
    }

string s is still showing me the OLD text which is populated before. I want to store new string which user entered. How do I do that?


make sure you repopulate rows and call DataBind at least on PageLoad, preferably on OnIniti without doing that, you always get values from viewstate (if you didnt disable it). at a last resort, you can investigate Request.Form and find if you recieved new value properly


Can't you use e.NewValues[] . The result that you are getting is probably e.OldValues[]

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜