一个小问题,期待解决~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<asp:datagrid id= "DataGrid1 " runat= "server " CssClass= "DataGrid " AllowPaging= "True " Width= "247px "
AutoGenerateColumns= "False " Font-Size= "12px ">
<Columns>
<asp:TemplateColumn>
<ItemTemplate>
<asp:LinkButton id= "a1 " runat= "server " CommandName= "lk ">
<%# DataBinder.Eval(Container.DataItem, "tel_num ")%>
</asp:LinkButton> </ItemTemplate>
</asp:TemplateColumn>
<asp:BoundColumn DataField= "is_assigned "> </asp:BoundColumn>
</Columns>
<PagerStyle Visible= "False "> </PagerStyle>
</asp:datagrid>
======================================
CS代码:
private void DataGrid1_ItemCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e)
{
if(e.CommandName == "lk ")
{
...............
}
}
===================================
我想问的是,当我点击模板列中的linkbutton时。取的我点的那个linkbutton的值。然后传给B.aspx。
=====================================
我搞了好久,拜托各位大虾了。
分数我只给一个人哦。
------解决方案-------------------- <a href= 'b.aspx?id= <%# DataBinder.Eval(Container, "DataItem.merchid ") %> &bid= <%# DataBinder.Eval(Container, "DataItem.merchid ") %> '> TestPage </a>
------解决方案-------------------- <asp:GridView ID= "grid " runat= "server " OnRowCommand= "grid_RowCommand ">
<Columns>
<asp:TemplateField>
<ItemTemplate>
<asp:LinkButton ID= "lbtn_1 " CommandArgument= ' <%#Eval( "key ") %> ' runat= "server " CommandName= "comand "> </asp:LinkButton>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
protected void grid_RowCommand(object sender, GridViewCommandEventArgs e)
{
if (e.CommandName == "comand ")
{
Response.Write(e.CommandArgument.ToString());
}
}
------解决方案--------------------如果单纯的传的话
<a href= 'b.aspx?id= <%# DataBinder.Eval(Container.DataItem, "tel_num ")%> '> <%# DataBinder.Eval(Container.DataItem, "tel_num ")%> </a>
其余的好像不需要了
------解决方案--------------------if(e.CommandName == "lk ")
{
LinkButton lk = (LinkButton)e.Item.FindControls( "a1 ");
Response.Redirect( "b.aspx?tel_num= " + lk.Text);
}
b.aspx
Response.Write(Request.QueryString[ "tel_num "]);
------解决方案--------------------linkbutton.PostBackUrl=b.aspx?zhi= <%# eval( "值 ")%>
在b.aspx里面取到Request.QueryString[ "zhi "]
我不知道你是不是要这种效果?
------解决方案--------------------添加一个新列。。 里面放ID值 隐藏起来。。
然后用
if(Convert.ToInt32(e.Item.Cells[0].Text) == Convert.ToInt32(this.DataGrid1.DataKeys[e.Item.ItemIndex]))