Hey everyone I am trouble getting a reference to dropdownlist1. I need to get the selectedvalue so I can use the sqldatasource to update the table in my database. How can I get a reference to dropdownlist1. I have used Page.FindControl(), but I still am getting a null pointer exception.
Thanks
Here is the code:
<asp:GridView ID="GridView1" runat="server" AllowPaging="True"
AutoGenerateColumns="False" DataSourceID="SqlDataSource2"
Width="886px" style="margin:auto;" CellPadding="4" ForeColor="#333333"
GridLines="None" DataKeyNames="UserID"
onrowupdating="GridView1_RowUpdating" >
<AlternatingRowStyle Font-Names="Calibri" Height="5" BackColor="White" />
<Columns>
<asp:CommandField ShowEditButton="True" />
<asp:BoundField DataField="UserID" HeaderText="UserId" SortExpression="UserId"
Visible="False" />
<asp:BoundField DataField="FirstName" HeaderText="First Name"
SortExpression="FirstName" />
<asp:BoundField DataField="ListName" HeaderText="Last Name"
SortExpression="ListName" />
<asp:BoundField DataField="UserName" HeaderText="User Name"
SortExpression="UserName" />
<asp:TemplateField HeaderText="Role Name" SortExpression="RoleName">
<EditItemTemplate>
<asp:DropDownList ID="DropDownList1" runat="server"
DataSourceID="SqlDataSource1" DataTextField="RoleName"
DataValueField="RoleID" AutoPostBack="True">
</asp:DropDownList>
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:AdvisementDB %>"
SelectCommand="sp_getRoles" SelectCommandType="StoredProcedure" >
</asp:SqlDataSource>
</EditItemTemplate>
<ItemTemplate>
<asp:Label ID="Label1" runat="server" Text='<%# Bind("RoleName") %>'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:BoundField DataField="StudentID" HeaderText="Student ID"
SortExpression="StudentID" />
<asp:BoundField DataField="LastActivityDate" HeaderText="Last Activity Date"
SortExpression="LastActivityDate" />
</Columns>
<EditRowStyle BackColor="#2461BF" />
<FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
<HeaderStyle Font-Names="Calibri" BackColor="#507CD1" Font-Bold="True"
ForeColor="White" />
<PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center" />
<RowStyle Height="5px" BackColor="#EFF3FB" />
<SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" />
<SortedAscendingCellStyle BackColor="#F5F7FB" />
<SortedAscendingHeaderStyle BackColor="#6D95E1" />
<SortedDescendingCellStyle BackColor="#E9EBEF" />
<SortedDescendingHeaderStyle BackColor="#4870BE" />
</asp:GridView>