简体   繁体   中英

gridview inside gridview… forum functionality

I have a question regarding gridview inside gridview's selection functionality . I am trying to achieve forum functionality.. ie A thread is posted and people comment on that thread . one can quote from earlier posted comments, add his opinions and finally make his comment.

I am binding the inside gridview's data on RowDataBound event of parent gridview. In database I have a Parent ID columns which have the ID of the Thread post on which the reply is made. so far simple reply(without quoting any of earlier comments) functionality is working just fine.

Now I am having an issue on quoting scenario.. I've a button inside the inner gridview(gridview2)'s item template..upon clicked which should give me the ID of that post. but i am unable to figure out any solution yet..as gridview2 is not accessible in .cs file

You can't directly access any control inside the gridview from code behind. You have to first make the object of that control.

GridView GridView2=(GridView)GridView1.Rows[RowIndex].FindControl("GridView2");

Something like this.
Refer this: http://www.codeproject.com/Articles/189997/Gridview-inside-Gridview-in-asp-net-Csharp . It may help you.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM