lundi 3 septembre 2018

Compute the ReadOnly column in real time in gridview and save the computed value to SQL server

I am trying to compute the column in real time meaning the calculation should be seen before an edit link is clicked. The weight first half is already found in the gridview. The gridview is then edited to add the rating first half. the 2, weight first half and rating first half needs to be multiplied to get the result that is score first half and score first half i made it a ReadOnly. Now i want the score first half to be saved in the SQL database. Mind you i already have the update command that the sqldatasource generate.

Here are the codes,

<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataKeyNames="P_C_ID" DataSourceID="SqlDataSource1">
                                            <Columns>
                                                <asp:CommandField ShowEditButton="True" />
                                                <asp:TemplateField HeaderText="P_C_ID" InsertVisible="False" SortExpression="P_C_ID">
                                                    <EditItemTemplate>
                                                        <asp:Label ID="Label1" runat="server" Text='<%# Eval("P_C_ID") %>'></asp:Label>
                                                    </EditItemTemplate>
                                                    <ItemTemplate>
                                                        <asp:Label ID="Label1" runat="server" Text='<%# Bind("P_C_ID") %>'></asp:Label>
                                                    </ItemTemplate><asp:TemplateField HeaderText="WEIGHT_FIRST_HALF" SortExpression="WEIGHT_FIRST_HALF">
                                                <EditItemTemplate>
                                                    <asp:TextBox ID="TextBox5" runat="server" ReadOnly="True" Text='<%# Bind("WEIGHT_FIRST_HALF") %>'></asp:TextBox>
                                                </EditItemTemplate>
                                                <ItemTemplate>
                                                    <asp:Label ID="Label6" runat="server" Text='<%# Bind("WEIGHT_FIRST_HALF") %>'></asp:Label>
                                                </ItemTemplate>
                                            </asp:TemplateField><ItemTemplate>
                                                    <asp:Label ID="Label9" runat="server" Text='<%# Bind("SCORE_FIRST_HALF") %>'></asp:Label>
                                                </ItemTemplate>  </Columns>
                                    </asp:GridView><asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:AWPConnectionString5 %>"UpdateCommand="UPDATE [Performance_Rating_2] SET [WEIGHT FIRST HALF]  = @WEIGHT_FIRST_HALF, [RATING FIRST HALF] = @RATING_FIRST_HALF, [SCORE FIRST HALF], [RATING FIRST HALF] = @RATING_FIRST_HALF = @SCORE_FIRST_HALF WHERE [P_C_ID] = @P_C_ID"><asp:Parameter Name="WEIGHT_FIRST_HALF" Type="Decimal" /><UpdateParameters><asp:Parameter Name="RATING_FIRST_HALF" Type="Int32" />
                                            <asp:Parameter Name="SCORE_FIRST_HALF" Type="Decimal" /></UpdateParameters>

Okay folks the program is long. I just took part that is not working fine. But shoukd you need clarity do not hesitate to ask for clarity. Right now only the weight and rating is being saved. the computed is not saved at all. I actually do not want to make it in C# codes as i need results in real time




Aucun commentaire:

Enregistrer un commentaire