Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Nested Gridview - RowDataBound Question

Status
Not open for further replies.

rsshetty

Programmer
Dec 16, 2003
236
US
I have the following structure on my aspx page:

Code:
<asp:Repeater id="myRepeater" runat="server" OnItemDataBound="myRepeater_ItemDataBound">
<ItemTemplate>

                    <asp:GridView ID="gvStudentList" runat="server" AutoGenerateColumns="false"  >
                        
                        
...

</asp:GridView>
                    
                    </ItemTemplate>
                    </asp:Repeater>

My question is this:

How can I access the OnRowDataBound and the OnRowCreated event of the inner Gridview?

Thanks

rsshetty.
It's always in the details.
 
In the HTML of the nested grid you can do something like this:
Code:
<asp:GridView ID="gvStudentList" runat="server" AutoGenerateColumns="false"  OnRowDataBound="gvNestedRowDataBound">

Then in your code behind create an event handler with the appropriate signature:
Code:
    Protected Sub gvNestedRowDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs)
   'Do Stuff Here....
End Sub
 
Thats what I thought. I keep getting an error -
The name 'gvStudentList' does not exist in the current context

Code:
protected void gvStudentList_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        //data row
        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            // Check IsExcluded & IsVerified for handling controls
            bool l_IsExcluded = Convert.ToBoolean(DataBinder.Eval(e.Row.DataItem, "is_excluded"));

            // LNF
            if (m_IsProbeLNF)
            {
                gvStudentList.Columns[3].Visible = true;

rsshetty.
It's always in the details.
 
The code behind will not recognize the name of your nested grid because it is in a template column. Just follow my example with any name you want to call the sub that handels the rowdataboundevent.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top