This question is actually two questions. I need to produce a gridview, with one column being a drop down selection.
I have the following code:
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataSourceID="ProjectsODS" OnRowUpdated="GridView1_RowUpdated" DataKeyNames="Id"
CssClass="mGrid"
PagerStyle-CssClass="pgr"
AlternatingRowStyle-CssClass="alt" ShowHeaderWhenEmpty="True" OnRowEditing="GridView1_RowEditing">
<Columns>
<asp:BoundField DataField="Name" HeaderText="Project Name" />
<asp:BoundField DataField="ProjectCode" HeaderText="Code" />
<asp:TemplateField HeaderText="Access">
<ItemTemplate>
<asp:DropDownList runat="server" AutoPostBack="True">
<asp:ListItem
Enabled="True"
Text="No Access"
Value="Test" />
<asp:ListItem
Enabled="True"
Text="Read Only"
Value="Tes 2" />
</asp:DropDownList>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
The last column is indeed a drop down. But, at the moment, I am hard coding items in it, to see how it will render. I need to actually bind values from another ObjectDataSource. But for each row in the grid, it's the same data. Will it hit the ODS for each row, or is the data read into the ODS once, and used by each row?
How do I link the ODS to the DropDownLists?
Then, how do I get the selected value set to be a value from the row? That is, the data source that produces the gridview has a field called "AccessTypeId". I need that value to be used to select the value of the DDL. How would I do that?
And then, I have set AutoPostBack to true. Once the DDL gets a new value set by the user, I want it to post the value. But, what even on the Grid is called when the DDL selected value is changed?