如何点击按钮获取gridview中的某一列的值!
展开全部
要将gridview的列转换成模板。。。。
这样才方便取值
取值方法如下:
string id = (GridView1.Rows[e.RowIndex].FindControl("TextBox2") as TextBox).Text;
为什么是textbox
将gridview的列转换成模板以后,你在VS里面查看源代码,看你的gridview,就知道为什么了
这样才方便取值
取值方法如下:
string id = (GridView1.Rows[e.RowIndex].FindControl("TextBox2") as TextBox).Text;
为什么是textbox
将gridview的列转换成模板以后,你在VS里面查看源代码,看你的gridview,就知道为什么了
本回答被提问者和网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
2011-07-06
展开全部
前台Gridview中:
<ItemTemplate>
<asp:LinkButton ID="LinkButton2" runat="server" CommandName="MyCommandList" CommandArgument='<%#Eval("MacID")%>'
OnClientClick="return Show()" Text='<%# Eval("Day_StartShut")%>' ></asp:LinkButton>
</ItemTemplate>
后台方法:
if (e.CommandName == "MyCommandList")
{
LinkButton btn = (LinkButton)e.CommandSource;
GridViewRow row = (GridViewRow)btn.Parent.Parent;
string MacID = e.CommandArgument.ToString();
string sql = "SELECT MacID,Day_StartUp,Day_ShutDown,ABS(Day_StartUp-Day_ShutDown) AS Day_StartShut,col_date";
sql += " From DW10048 WHERE (col_date>='" + txtStartDay.Value + "' and col_date <='" + txtEndDay.Value + "') and macid = '" + MacID + "'";
sql +=" order by col_date desc";
DataTable dtlist = l_Help.GetDataTable(sql);
DataView view = dtlist.DefaultView;
GvList1.DataSource = view;
GvList1.DataBind();
}
另外,虚机团上产品团购,超级便宜
<ItemTemplate>
<asp:LinkButton ID="LinkButton2" runat="server" CommandName="MyCommandList" CommandArgument='<%#Eval("MacID")%>'
OnClientClick="return Show()" Text='<%# Eval("Day_StartShut")%>' ></asp:LinkButton>
</ItemTemplate>
后台方法:
if (e.CommandName == "MyCommandList")
{
LinkButton btn = (LinkButton)e.CommandSource;
GridViewRow row = (GridViewRow)btn.Parent.Parent;
string MacID = e.CommandArgument.ToString();
string sql = "SELECT MacID,Day_StartUp,Day_ShutDown,ABS(Day_StartUp-Day_ShutDown) AS Day_StartShut,col_date";
sql += " From DW10048 WHERE (col_date>='" + txtStartDay.Value + "' and col_date <='" + txtEndDay.Value + "') and macid = '" + MacID + "'";
sql +=" order by col_date desc";
DataTable dtlist = l_Help.GetDataTable(sql);
DataView view = dtlist.DefaultView;
GvList1.DataSource = view;
GvList1.DataBind();
}
另外,虚机团上产品团购,超级便宜
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
this.GridView1.Rows[e.NewEditIndex].Cells[0].Text
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询