I've been having troubles getting my textbox to refresh a GridView from the onchange event.
The GridView is linked up to a LINQ data source and the LINQ data source has a Where Parameter UserId that it gets from the textbox... Here's the code:
<asp:Label ID="label_UserId" runat="server" Text="Search by User Id: "></asp:Label>
<asp:TextBox ID="textbox_UserId" Text="12" runat="server"
ontextchanged="textbox_UserId_TextChanged"></asp:TextBox>
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False"
DataKeyNames="UserID" DataSourceID="LINQUserSource"
EmptyDataText="There are no data records to display.">
<Columns>
<asp:BoundField DataField="UserID" HeaderText="UserID" ReadOnly="True"
SortExpression="UserID" />
<asp:BoundField DataField="Username" HeaderText="Username"
SortExpression="Username" />
<asp:BoundField DataField="FirstName" HeaderText="FirstName"
SortExpression="FirstName" />
<asp:BoundField DataField="LastName" HeaderText="LastName"
SortExpression="LastName" />
<asp:BoundField DataField="Email" HeaderText="Email" SortExpression="Email" />
</Columns>
</asp:GridView>
<asp:LinqDataSource ID="LINQUserSource" runat="server"
ContextTypeName="DotNetNuke.Modules.Report.UsersDataContext"
Select="new (UserID, Username, FirstName, LastName, Email)" Where="UserId = @UserId"
TableName="Users">
<WhereParameters>
<asp:ControlParameter
Name="UserId"
DefaultValue="0"
ControlID="textbox_UserId"
Type="Int32" />
</WhereParameters>
</asp:LinqDataSource>
So far I have nothing for the backend code. Since I set the textbox to be 12 by default, the GridView loads with the record of UserId 12, but now I want the GridView to reload if I change the number in the textbox. Any ideas?
Thanks,
Matt