开发者

Obtaining the ctl property from a gridview control in C#, ASP.Net

I am trying to obtain the ctl property that is specific to each row in a gridview. In my scenario, there is a list of titles, each title is displayed as a hyperlink using the LinkButton. When this is clicked, I would like to pass the ctl property (or what ever value is specific to that title, to the database and pull the information that is relative to the value).

I guess my first step is to obtain the ctl value. Co开发者_运维技巧uld someone please help me get on my way. Thanks in advance.


You will need to keep track of the control ID that is written to the page in the row created event. Make a integer to increment for each row written and save it as a command argument on a link in the grid.

linkbutton CommandArgument='<%# Eval("some_id") %>' 

protected void linkButton_Click(object sender, EventArgs e)
{

    LinkButton linkButton = (LinkButton) sender;           
    if (linkButton != null)
    {
        if (linkButton.CommandArgument != null)
        {
            ...some code...
        }
    }

}
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜