Accessing ObjectDataSource within Gridview EditItemTemplate

D

Dom

Hello

This should work I know ... but.. with your help perhaps..

Trying to assign a 'selectparameter' to an objectdatasource nested
within a gridview EditItemTemplate.

When I try to access access the object in the OnRowDataBound event am
getting a null

However am able to access the object in the OnRowUpdating event.

Would appreciate any guidance... Code below.

ASPX

asp:GridView Width="100%" ID="clientTasksGrid" runat="server"
AutoGenerateColumns="False"
DataKeyNames="clientTaskId, clientId" DataSourceID="IssueDS"
AllowSorting="True" CellPadding="4"
AllowPaging="True" PageSize="15" GridLines="None"
HeaderStyle-HorizontalAlign="left"
OnRowUpdating="GridView_RowUpdating="
OnRowDataBound="GridView_RowDataBound">
<Columns>
<asp:TemplateField>
<ItemTemplate>
<asp:Label Font-Bold="true" ID="clientLabel" runat="server"
Text='<"%# HttpUtility.HtmlEncode(Convert.ToString(Eval("clientName")))
%>'/>
</ItemTemplate>
<EditItemTemplate>
<!--Projects -->
<asp:ObjectDataSource ID="ProjectData" runat="server"
TypeName="Project"
SelectMethod="GetAllProjects">
</asp:ObjectDataSource>
<asp:DropDownList ID="ProjectList" runat="server" AutoPostBack="True"
CssClass="ProjectCategories"
DataSourceID="ProjectData" DataTextField="Name" DataValueField="Id"
/>
</EditItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>


protected void GridView_RowDataBound(object sender,
GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{

// ObjectDataSource tempProjectDataSource =
(ObjectDataSource)row.FindControl("ProjectData");

}
}


Thank you for your assistance
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,070
Latest member
BiogenixGummies

Latest Threads

Top