首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >如何使字符串可被按钮访问?

如何使字符串可被按钮访问?
EN

Stack Overflow用户
提问于 2019-02-14 20:50:47
回答 4查看 82关注 0票数 0

我需要保存通过选择要在按钮保护的void中使用的行而得到的刺痛。

代码语言:javascript
运行
复制
protected void Button2_Click(object sender, EventArgs e)
{
    string = id <= how to get the string here?
}

protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
{
    GridViewRow row = GridView1.SelectedRow;
    string id = row.Cells[3].Text;
}
EN

Stack Overflow用户

发布于 2019-02-15 01:03:41

最简单的是:

将Button2设置为在启动时禁用...

代码语言:javascript
运行
复制
protected void Button2_Click(object sender, EventArgs e)
{
    string id = GridView1.SelectedRow.Cells[3].Text;
}

// only allow the button to be enabled if there is a selected row
protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
{        
    if (GridView1.SelectedRow != null){
        Button2.Enabled = true;
    } else {
        Button2.Enabled = false;
    }
}
票数 0
EN
查看全部 4 条回答
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/54690845

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档