GridView RowEditing - 如何使一个事件触发更改到同一行中的另一个控件? [英] GridView RowEditing - How to make an event that triggers change to another control in the same row?
问题描述
假设我有以下情况:
- 我有一个GridView,我刚推了编辑按钮,所以我触发了RowEditing事件
- 我看到2个可编辑的列:Date和周
- "日期"是一个日期时间类型,当前的WebUi控件是日历
- " Week"是一个int类型,当前的WebUi控件是TextBox
我的问题:
假设我选择了一个特定的日期,并且我有一个函数用datetime计算ISO-Week作为输入;在Calendar控件中更改SelectedDate后,是否可以更新Week文本框?记住这发生在当前的RowEditing索引中。
欢迎所有建议!
Suppose I have the following situation:
- I have a GridView, and I have just pushed the "Edit" button, so I have triggered RowEditing event
- I see 2 editable columns: "Date" and "Week"
- "Date" is a datetime type, current WebUi control is Calendar
- "Week" is an int type , current WebUi control is TextBox
My question:
Suppose I select a specific date, and that I have a function that calculates ISO-Week with datetime as input; Is it possible to update the Week textbox after changing SelectedDate in the Calendar control? Remember this is happening inside the current RowEditing index.
All suggestions are gladly welcome!
推荐答案
谢谢你这么厉害!像宝石一样工作! :)
很多爱< 3
Thank you so much! Works like a gem! :)
Much love <3
尝试从网格行编辑器获取如下的文本框,然后设置其值on datetime change event handler: -
在日期更改事件处理程序中,您可以这样做:
Try getting the week textbox as below from grid row editor, then setting its value on datetime change event handler :-
On date change event handler you can do like this :
//get the index of the row in edit mode
int index = AuthorsGridView.EditIndex;
// get the row by index from grid
GridViewRow row = AuthorsGridView.Rows[index];
// find the textbox from the row
TextBox txtWeek = (TextBox)row.FindControl("txtWeek");
// Now set the text of textbox as desired
希望这对您有所帮助。
Hope this will be of help to you.
这篇关于GridView RowEditing - 如何使一个事件触发更改到同一行中的另一个控件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!