我想在gridview里添加一个按钮,点这个按钮后可以查看这一行信息更详细的信息。要怎么办呢?
我现在这样写,但是都说e.RowIndex缺少命名空间呢,但是我查过不少的啊~~<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False"
Width="90%" AllowPaging="True" PageSize="15" style="margin-top:0px" AllowSorting="True"
onpageindexchanging="GridView1_PageIndexChanging"
onsorting="GridView1_Sorting" Font-Bold="True"
onrowcommand="GridView1_RowCommand" onrowediting="GridView1_RowEditing">
<Columns>
<asp:BoundField DataField="local_name" HeaderText="地区" SortExpression="local_name" />
<asp:TemplateField>
<ItemTemplate>
<asp:LinkButton ID="check_info" runat="server" CommandName="checks">查看详情</asp:LinkButton>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>后台代码就一句话,可是都说e.RowInde有问题
protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
{
Label3.Text = GridView1.DataKeys[e.RowIndex].Value.ToString();
}
我现在这样写,但是都说e.RowIndex缺少命名空间呢,但是我查过不少的啊~~<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False"
Width="90%" AllowPaging="True" PageSize="15" style="margin-top:0px" AllowSorting="True"
onpageindexchanging="GridView1_PageIndexChanging"
onsorting="GridView1_Sorting" Font-Bold="True"
onrowcommand="GridView1_RowCommand" onrowediting="GridView1_RowEditing">
<Columns>
<asp:BoundField DataField="local_name" HeaderText="地区" SortExpression="local_name" />
<asp:TemplateField>
<ItemTemplate>
<asp:LinkButton ID="check_info" runat="server" CommandName="checks">查看详情</asp:LinkButton>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>后台代码就一句话,可是都说e.RowInde有问题
protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
{
Label3.Text = GridView1.DataKeys[e.RowIndex].Value.ToString();
}
可是我现在有一个这个字段
<asp:BoundField DataField="ip_address" HeaderText="IP地址" SortExpression="ip_address" /> 然后我想让CommandArgument="<%#Eval("ip_address") %>",就会报错,创建控件时出错——gridview1服务器标记的格式不正确
是怎么回事呢?