开发者

How to access boundfield values in a Gridview Control?

I have a grid view control having some bound and template fields as follows

<asp:BoundField DataField="ID" HeaderText="ID" InsertVisible="False" 
ReadOnly="True" SortExpression="ID" Visible="False" />
<asp:TemplateField HeaderText="Question">开发者_C百科
<ItemTemplate>
<asp:LinkButton ID="btnques" runat="server" onclick="btnques_Click" 
Text='<%# bind("Question") %>'></asp:LinkButton>
</ItemTemplate>
</asp:TemplateField>

Now, what I want to do is that on the click event of a buttom btnques, I want to access its corressponding boundfield ID's value and store it in a label. Can anyone tell me how to do this ...


should be like

 Text='<%# bind("Question") %> CommandArgument='<%# Eval("QuestionId") %>'

and then in code behind you can acess like...

protected void grd_RowCommand(object sender, GridViewCommandEventArgs e)
{
    if (e.CommandName == "")
    {
       e.CommandArgument // will return the id 
    }        
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜