Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
310
TemplateDataField with text box and drop down list will not update data source
posted

I have a WebDataGrid containing numerous TemplateDataFields.  Each TemplateDataField contains one text box and one drop down list.  I want the user to alter the contents of the text box and drop down list then click a button which will cause the data source to update.

Right now my data source is not updating when I change the contents of the text box and drop down list and click the button.

 

Here is my SqlDataSource with the update command and parameters:

 

<asp:SqlDataSource ID="SqlDataSource1" runat="server"

ConnectionString="<%$ ConnectionStrings:ConnectionString %>"

ConflictDetection="OverwriteChanges"

OldValuesParameterFormatString="original_{0}"

SelectCommand="SELECT * FROM [MAR]"

UpdateCommand="UPDATE [MAR] SET [PatientID] = @PatientID, [StudentID] = @StudentID, [Start] = @Start, [EndTime] = @EndTime, [Med] = @Med, [Schedule] = @Schedule, [MAR1] = @MAR1, [MARStatus1] = @MARStatus1 WHERE [ID] = @original_ID AND [PatientID] = @original_PatientID AND [StudentID] = @original_StudentID AND [Start] = @original_Start AND [EndTime] = @original_EndTime AND [Med] = @original_Med AND [Schedule] = @original_Schedule AND [MAR1] = @original_MAR1 AND [MARStatus1] = @original_MARStatus1">

 

Here is my WebDataGrid with the TemplateDataField:

 

<ig:TemplateDataField Key="mars1" Width="60px">

<Header Text="1" />

<ItemTemplate>

<asp:TextBox ID="TBMars1" runat="server" Text='<%# Eval("MAR1")%>'>

asp:TextBox>

<asp:DropDownList ID="DDLMars1" runat="server">

<asp:ListItem Text="" Value="">asp:ListItem>

<asp:ListItem Text="Held" Value="Held">asp:ListItem>

<asp:ListItem Text="Given" Value="Given">asp:ListItem>

<asp:ListItem Text="Refused" Value="Refused">asp:ListItem>

asp:DropDownList>

ItemTemplate>

ig:TemplateDataField>

 

Here is my VB.net function that handles the button click event:

 

Protected Sub iBTNSaveMeds_Click(sender As Object, e As Infragistics.WebUI.WebDataInput.ButtonEventArgs) Handles iBTNSaveMeds.Click

        SqlDataSource1.Update()

End Sub