I have a gridview bound with a database. I would like to add an extra column which has a linkbutton. The intention is that when clicked on the linkbutton, the user could toggle the value of a column which is bounded with the database.

I don't have any good ideas how to get started on this. Any help would be greatly appreciated!

Regards, Thijs

有帮助吗?

解决方案

If I understand you question,

Make you gridview template fields. you can find more about Using TemplateFields in the GridView Control

Place the linkbutton with a commandname. See ButtonField.CommandName Property

In here do the same for the field you need to access. You will be able to access the values and change as you need.

Hope this helps

其他提示

Right the way I would approach this is declare a class called GridRecord or something that represents a grid row.

class GridRecord
{
}

then in the class define all properties that will be the columns of your grid including the link column.

class GridRecord
{
    private Image m_Link = [some image];
    public GridRecord(){}

    public Image Link
    {
        get { return m_Link; }
    }
}

then in your grid code:

IList<GridRecord> records = new List<GridRecords>();
//Fill records object as you like.
Grid1.DataSource = records;

Then handle the RowCellClick or similar event and check if the clicked cell is of property type Link and use it.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top