简体   繁体   中英

How to set cell values programatically in a GridView?

Work on Asp.Net C# VS08.

I have a GridView which was binded to an ObjectDataSource with edit command link capabilities enabled.

Whenever the user go on edit a row and changes a given cell, I'd like to change another cell value programatically change a cell value (according to the new cell value typed by the user).

So, is it possible to change cell values programatically on edit mode?

I took a gridview with Five columns. In first column i have edit buttons. In second column i have name and in third i have age,StartTime,EndTime.On my name cell i used PopupControlExtender ,When user click on Name Cell they see a gridview popup containing Name And Age from there they chose appropriate name.After chose the name i want Age will be set Automatically on My Age cell.

Where to Write,How to write methods.On PopupControlExtender popup grid i can select and set value on name cell using the bellow code

 protected void GridView2_SelectedIndexChanged(object sender, EventArgs e)
        {
            string b = ((Label)GridView2.SelectedRow.FindControl("lblCOM_NAME")).Text;
            AjaxControlToolkit.PopupControlExtender.GetProxyForCurrentPopup( this.Page).Commit(b);
        }

i want user click the name cell value after this age will be set automatically on Age cell from popup grid.How to set the Value?

Use a template column and then

row[0].Cell[0].FindControl("txtTextBox")

with the correct cast.

I dont have VS on this machine but that should be about right.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM