添加一个模板列,其中访一个button,就可以实现下面的代码我是用linkbutton的,稍微改一下就okprotected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
{
if (e.CommandName == "fuqu")
{
int rowindex = Convert.ToInt32(e.CommandArgument);
Label lb = (Label)GridView1.Rows[rowindex].FindControl("lbID");
Label lb1 =(Label)GridView1.Rows[rowindex].FindControl("lbWellID");
string dataid = lb.Text;
string orgid = ddl_Org.SelectedValue;
string WellID = lb1.Text ;
string Date = tb_Date.Text;
Response.Redirect("FuQuDetail.aspx?&ID=" + dataid + "&OrgID=" + orgid + "&WellID=" + WellID + "&Date=" + Date);
}
}
protected void GridView1_RowCreated(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
LinkButton lb = (LinkButton)e.Row.FindControl("lbDetail");
lb.CommandArgument = e.Row.RowIndex.ToString();
}
}
{
if (e.CommandName == "fuqu")
{
int rowindex = Convert.ToInt32(e.CommandArgument);
Label lb = (Label)GridView1.Rows[rowindex].FindControl("lbID");
Label lb1 =(Label)GridView1.Rows[rowindex].FindControl("lbWellID");
string dataid = lb.Text;
string orgid = ddl_Org.SelectedValue;
string WellID = lb1.Text ;
string Date = tb_Date.Text;
Response.Redirect("FuQuDetail.aspx?&ID=" + dataid + "&OrgID=" + orgid + "&WellID=" + WellID + "&Date=" + Date);
}
}
protected void GridView1_RowCreated(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
LinkButton lb = (LinkButton)e.Row.FindControl("lbDetail");
lb.CommandArgument = e.Row.RowIndex.ToString();
}
}
解决方案 »
- 急~~日期比较问题 在线等....
- 委托,事件传值:传值了,取数据用GDI重新绘制图
- .net使用Graphics画线问题,具体内容看里面
- 初学C#,[MarshalAs(UnmanagedType.ByValTStr, SizeConst = 12)],什么意思?
- WPF中richtextbox中的图片在拖曳出windows后e.Data被重置怎么弄?
- win form 下datagrid 怎么一次选择多行
- 怎么样截获系统的消息,读取消息队列
- 高手进,棘手问题,进言有分
- 有学asp.net的吗?欢迎进来看看
- C#怎么调用编译方式为<<嵌入的资源>>的dll文件
- winform中怎么读EXCEL中工作薄的名称
- DataGridView怎样实现把数据按组分页显示 (在线等,急)
<HeaderTemplate>
<asp:LinkButton ID="asp_lnbWorkflowName" OnCommand="Step1_GridView_Sort_Select" CommandName="asp_grvStep1_SelectWorkflow" CommandArgument="WorkflowName" runat="server"></asp:LinkButton>
</HeaderTemplate>
<ItemTemplate>
<asp:Image ID="asp_imgWorkflow" runat="server" ImageUrl="../../images/list_flow.gif"/>
<asp:HyperLink ID="asp_hypWorkflowDetail" Target="_blank" Text='<%# Server.HtmlEncode((string)DataBinder.Eval(Container, "DataItem.WorkflowName")) %>' NavigateUrl="#" runat="server"></asp:HyperLink>
<asp:HiddenField ID="asp_hidWorkflowId" Value='<%# DataBinder.Eval(Container, "DataItem.WorkflowId") %>' runat="server" />
</ItemTemplate>
</asp:TemplateField>
在GridView的rowDataBound的事件里,将HyperLink的NavigateUrl设成你需要的地址。就Ok了。