I'm doing some complicated things with a gridview and the only thing standing between me and completion is the fact that I can't set the databinding programmatically. I've made it most of the way around this issue except that I still cannot get the datasource to update.
I've replaced one input field with a dependent dropdownlist and gotten it to retain the value of the field on databind. I can't databind it directly because I get 'Selected Value not in list of items' or something, so I have to find a way to get the grid or the datasource to take the value from this dependent drop down and apply it to the table.
Any help?
<asp:GridView ID="gvManager" runat="server"
AutoGenerateColumns="False" DataSourceID="ldsCampaigns"
ondatabound="gvManager_DataBound"
onrowediting="gvManager_RowEditing" DataKeyNames="ContentID">
<Columns>
<asp:CommandField ShowEditButton="True" />
<asp:BoundField DataField="ContentID" HeaderText="ContentID"
SortExpression="ContentID" />
<asp:BoundField DataField="CampaignName" HeaderText="CampaignName"
SortExpression="CampaignName" />
<asp:BoundField DataField="CampaignTitle" HeaderText="CampaignTitle"
SortExpression="CampaignTitle" />
<asp:BoundField DataField="CampaignTagLine" HeaderText="CampaignTagLine"
SortExpression="CampaignTagLine" />
<asp:TemplateField HeaderText="CampaignData" SortExpression="CampaignData">
<EditItemTemplate>
<asp:DropDownList ID="DropDownList1" runat="server" DataSourceID="ldsTables"
DataTextField="CMSTables" DataValueField="CMSTables"
SelectedValue='<%# Bind("CampaignData") %>' onload="DropDownList1_Load">
</asp:DropDownList>
<asp:LinqDataSource ID="ldsTables" runat="server"
ContextTypeName="DataContext"
onselecting="ldsTables_Selecting" Select="new (CMSTables)"
TableName="CampaignTables">
</asp:LinqDataSource>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="Label1" runat="server" Text='<%# Bind("CampaignData") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="DataColumn"
SortExpression="DataColumn">
<EditItemTemplate>
<asp:DropDownList ID="DropDownList2" runat="server" style="margin-bottom: 0px"
SelectedValue='<%# Bind("DataColumn") %>' Visible="False">
</asp:DropDownList>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="Label2" runat="server"
Text='<%# Bind("DataColumn") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="CampaignLink" HeaderText="CampaignLink"
SortExpression="CampaignLink" />
<asp:BoundField DataField="Sunrise" HeaderText="Sunrise"
SortExpression="Sunrise" />
<asp:BoundField DataField="Sunset" HeaderText="Sunset"
SortExpression="Sunset" />
<asp:BoundField DataField="OwnerID" HeaderText="OwnerID"
SortExpression="OwnerID" />
<asp:CheckBoxField DataField="Enabled" HeaderText="Enabled"
SortExpression="Enabled" />
</Columns>
</asp:GridView>