Really struggline with how to populate a dropdownlist in a datagrid when i click the edit link:
VB Code:
Sub dgrdResults_PageIndexChanged (s as Object, e as DataGridPageChangedEventArgs) dgrdResults.CurrentPageIndex = e.NewPageIndex BindDataGrid End Sub Sub dgrdResults_CancelCommand(s as Object, e as DataGridCommandEventArgs) dgrdResults.EditItemIndex = -1 BindDataGrid End Sub Sub dgrdResults_UpdateCommand(s as Object, e as DataGridCommandEventArgs) Dim TempList as DropDownList Dim TempValue as String TempList = e.Item.FindControl("drpUnitRating") TempValue = TempList.SelectedItem.Value dgrdResults.EditItemIndex = -1 BindDataGrid End Sub Function BindRating() 'Dim colArrayList as New ArrayList 'colArrayList.Add("5") 'colArrayList.Add("4") 'colArrayList.Add("3") 'colArrayList.Add("2") 'colArrayList.Add("1") 'drpUnitRating.DataSource = colArrayList 'drpUnitRating.DataBind() End Function Sub dgrdResults_EditCommand(s as Object, e as DataGridCommandEventArgs) dgrdResults.EditItemIndex = e.Item.ItemIndex BindDataGrid End Sub ...... <asp:DataGrid ID="dgrdResults" AllowPaging="true" AutoGenerateColumns="false" PagerStyle-Mode="NumericPages" PagerStyle-PageButtonCount="5" PagerStyle-Position="Bottom" PageSize="25" OnPageIndexChanged="dgrdResults_PageIndexChanged" OnEditCommand="dgrdResults_EditCommand" OnUpdateCommand="dgrdResults_UpdateCommand" OnCancelCommand="dgrdResults_CancelCommand" CellPadding="0" BorderWidth="0" GridLines="None" CssClass="../fmcss.css" runat="server" > <columns> <asp:TemplateColumn> <itemTemplate> <%# Container.DataItem("PRD_BRAND") %> <%# Container.DataItem("PRD_MODEL") %> <%# Container.DataItem("PRD_NAME") %> <%# Container.DataItem("PRD_CATEGORY_CD") %> </itemTemplate> </asp:TemplateColumn> <asp:TemplateColumn> <itemTemplate> <%# Container.DataItem("UNIT_RATING") %> </itemTemplate> <edititemtemplate> <asp:DropDownList ID="drpUnitRating" DataTextField='<%# Container.DataItem("UNIT_RATING") %>' DataValueField='<%# Container.DataItem("UNIT_RATING") %>' DataSource='<%# BindRating %>' runat="server"></asp:DropDownList> </edititemtemplate> </asp:TemplateColumn> <asp:EditCommandColumn EditText="E" UpdateText="U" CancelText="C" /> </columns> </asp:DataGrid>
I can do it either by connecting to a database or by just typing in say 5 values 1-5. I will be doing it both ways once I figure out how to do this. Right now I am just trying to just do it without the connecting to a database.
Thanks in advance to any replies.




Reply With Quote