我有一个更新面板内的gridview。当我在编辑后单击“取消”时,没有任何反应。当我调试它确实进入我的gvWorkhours_RowCommand函数和取消if
内部,但屏幕上没有任何反应(编辑字段仍然可见)
这就是我所拥有的:
<asp:GridView ID="gvWorkhours" runat="server" AutoGenerateColumns="false" CssClass="GridViewStyle" OnRowEditing="gvWorkhours_RowEditing"
OnRowCommand="gvWorkhours_RowCommand" >
<EmptyDataTemplate>
no data returned
</EmptyDataTemplate>
<Columns>
<asp:commandfield buttontype="Link" showeditbutton="true" edittext="Edit" />
<asp:TemplateField HeaderText="Organization">
<ItemTemplate>
<%# Eval("org.orgCode").ToString() + "- " + Eval("org.orgSubCode").ToString()%>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Year-Qtr">
<ItemTemplate>
<%# Eval("year").ToString() + "- " + Eval("qtr").ToString()%>
</ItemTemplate>
</asp:TemplateField>
.......
protected void gvWorkhours_RowEditing(Object sender, GridViewEditEventArgs e)
{
populateGrid(); //pulls from the Db and binds to the grid
gvWorkhours.EditIndex = e.NewEditIndex; //This is the selected row to edit
gvWorkhours.DataBind(); //Make the edit Template show up
}
protected void gvWorkhours_RowCommand(Object sender, GridViewCommandEventArgs e)
{
// If multiple buttons are used in a GridView control, use the
// CommandName property to determine which button was clicked.
if (e.CommandName == "Cancel")
{
gvWorkhours.EditIndex = -1;
populateGrid();
}
}
private void populateGrid()
{
//getting all variables for update here.
Workhours wh = new Workhours(selectedItem, year, qtr);
gvWorkhours.DataSource = wh.exposures;
gvWorkhours.DataBind();
}
catch (Exception ex)
{
lblMessage.Text = ex.Message;
// throw(ex);
}
}
我在这里缺少什么?
答案 0 :(得分:1)
您的示例中没有显示UpdatePanel,因此我不知道您是如何设置它的,但是如果您将UpdateMode
设置为Conditional
,则可能需要在更新面板上手动调用Update
方法:
if (e.CommandName == "Cancel")
{
gvWorkhours.EditIndex = -1;
populateGrid();
UpdatePanel1.Update(); // whatever the name of the UpdatePanel is
}
答案 1 :(得分:0)
尝试提供除取消之外的其他单词,例如&#34; CancelRecord&#34;然后试试吧
答案 2 :(得分:0)
是的,这是一个老问题,但没有答案。
取消需要在RowCancelEdit方法中...似乎'取消'在这种情况下是受保护的单词
// numbers are 32bit signed integers!
while (true) {
basic.pause(30)
basic.clearScreen()
plotAA(input.acceleration(Dimension.X) + 255 * 2, input.acceleration(Dimension.Y) + 255 * 2, 255, 255)
//plotAAY(255 * 2, input.acceleration(Dimension.Y) + 255 * 2, 255, 255)
//plotAAX(input.acceleration(Dimension.X) + 255 * 2, 255 * 2, 255, 255)
}
function plotAAX(_x: number, _y: number, _brightness: number, _scale: number) {
let vertical = false;
/*
* Draw a dot without "staircase effect"/aliasing.
* _x : from 0 to 4 but in _scale scale
* _y : from 0 to 4 but in _scale scale
* _brightness : led brightness
*
* Half of _scale is a number of pixel center
*/
let px = (_x + _scale) % _scale * 2 // subpixel x position
let rx = (_x + _scale) / _scale - 1 // real x position (ceil)
let ry = (_y + _scale) / _scale - 1 // real y position (ceil)
led.plotBrightness(rx, ry, (_scale - px) * _brightness / _scale)
led.plotBrightness(rx + 1, ry, px * _brightness / _scale)
}
function plotAAY(_x: number, _y: number, _brightness: number, _scale: number) {
/*
* Draw a dot without "staircase effect"/aliasing.
* _x : from 0 to 4 but in _scale scale
* _y : from 0 to 4 but in _scale scale
* _brightness : led brightness
*
* Half of _scale is a number of pixel center
*/
let py = (_y + _scale) % _scale * 2 // subpixel y position
let rx = (_x + _scale) / _scale - 1 // real x position (ceil)
let ry = (_y + _scale) / _scale - 1 // real y position (ceil)
led.plotBrightness(rx, ry, (_scale - py) * _brightness / _scale)
led.plotBrightness(rx, ry + 1, py * _brightness / _scale)
}
function plotAA(_x: number, _y: number, _brightness: number, _scale: number) {
/*
* Draw a dot without "staircase effect"/aliasing.
* _x : from 0 to 4 but in _scale scale
* _y : from 0 to 4 but in _scale scale
* _brightness : led brightness
*
* Half of _scale is a number of pixel center
*/
let px = (_x + _scale) % _scale // subpixel x position
let py = (_y + _scale) % _scale // subpixel y position
// -(half of scale) to (half of scale)
let rx = (_x + _scale) / _scale - 1 // real x position (ceil)
let ry = (_y + _scale) / _scale - 1 // real y position (ceil)
led.plotBrightness(rx, ry, Math.max(_scale - distance(0, 0, px, py), 0) * _brightness / _scale)
led.plotBrightness(rx, ry + 1, Math.max(_scale - distance(0, _scale, px, py), 0) * _brightness / _scale)
led.plotBrightness(rx + 1, ry, Math.max(_scale - distance(_scale, 0, px, py), 0) * _brightness / _scale)
led.plotBrightness(rx + 1, ry + 1, Math.max(_scale - distance(_scale, _scale, px, py), 0) * _brightness / _scale)
}
function distance(_1x: number, _1y: number, _2x: number, _2y: number) {
_1x -= _2x
_1y -= _2y
return Math.sqrt(_1x * _1x + _1y * _1y)
}