Hov.. Nej nu virker det.. Men kun på første tekstboks.. Så i får lige den lange
"HTML":
- <asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
- <asp:TextBox ID="TextBox_Color" runat="server"></asp:TextBox>
- <asp:TextBox ID="TextBox_HoverColor" runat="server"></asp:TextBox>
- <br />
- <asp:TextBox ID="TextBox_TxtDecoration" runat="server"></asp:TextBox>
- <asp:TextBox ID="TextBox_HoverTxtDecoration" runat="server"></asp:TextBox>
- <br />
- <asp:TextBox ID="TextBox_FontFamily" runat="server"></asp:TextBox>
- <asp:TextBox ID="TextBox_HoverFontFamily" runat="server"></asp:TextBox>
- <br />
- <asp:TextBox ID="TextBox_Size" runat="server"></asp:TextBox>
- <asp:TextBox ID="TextBox_HoverSize" runat="server"></asp:TextBox>
- <br />
- <asp:TextBox ID="TextBox_FontWeight" runat="server"></asp:TextBox>
- <asp:TextBox ID="TextBox_HoverFontWeight" runat="server"></asp:TextBox>
- <br />
- <asp:TextBox ID="TextBox_Style" runat="server"></asp:TextBox>
- <asp:TextBox ID="TextBox_HoverStyle" runat="server"></asp:TextBox>
- <br />
- <asp:Button ID="Button_Submit_Styles" runat="server" Text="Submit"
- onclick="Button_Submit_Styles_Click" />
- </asp:Content>
Code Behind:
- protected void Button_Submit_Styles_Click(object sender, EventArgs e)
- {
- SqlConnection sqlconn1 = new SqlConnection(ConfigurationManager.ConnectionStrings["ConnectionString"].ToString());
-
- SqlCommand sqlcom1 = new SqlCommand("UPDATE LinkSheet_Table SET Style=@Color WHERE ID=1", sqlconn1);
- SqlCommand sqlcom2 = new SqlCommand("UPDATE LinkSheet_Table SET Style=@Color_Hover WHERE ID=2", sqlconn1);
- SqlCommand sqlcom3 = new SqlCommand("UPDATE LinkSheet_Table SET Style=@TxtDecoration WHERE ID=3", sqlconn1);
- SqlCommand sqlcom4 = new SqlCommand("UPDATE LinkSheet_Table SET Style=@TxtDecoration_Hover WHERE ID=4", sqlconn1);
- SqlCommand sqlcom5 = new SqlCommand("UPDATE LinkSheet_Table SET Style=@FontFamily WHERE ID=5", sqlconn1);
- SqlCommand sqlcom6 = new SqlCommand("UPDATE LinkSheet_Table SET Style=@FontFamily_Hover WHERE ID=6", sqlconn1);
- SqlCommand sqlcom7 = new SqlCommand("UPDATE LinkSheet_Table SET Style=@Size WHERE ID=7", sqlconn1);
- SqlCommand sqlcom8 = new SqlCommand("UPDATE LinkSheet_Table SET Style=@Size_Hover WHERE ID=8", sqlconn1);
- SqlCommand sqlcom9 = new SqlCommand("UPDATE LinkSheet_Table SET Style=@FontWeight WHERE ID=9", sqlconn1);
- SqlCommand sqlcom10 = new SqlCommand("UPDATE LinkSheet_Table SET Style=@FontWeight_Hover WHERE ID=10", sqlconn1);
- SqlCommand sqlcom11 = new SqlCommand("UPDATE LinkSheet_Table SET Style=@Style WHERE ID=11", sqlconn1);
- SqlCommand sqlcom12 = new SqlCommand("UPDATE LinkSheet_Table SET Style=@Style_Hover WHERE ID=12", sqlconn1);
-
- sqlcom1.Parameters.AddWithValue("@Color", TextBox_Color.Text);
- sqlcom2.Parameters.AddWithValue("@Color_Hover", TextBox_HoverColor.Text);
- sqlcom3.Parameters.AddWithValue("@TxtDecoration", TextBox_TxtDecoration.Text);
- sqlcom4.Parameters.AddWithValue("@TxtDecoration_Hover", TextBox_HoverTxtDecoration.Text);
- sqlcom5.Parameters.AddWithValue("@FontFamily", TextBox_FontFamily.Text);
- sqlcom6.Parameters.AddWithValue("@FontFamily_Hover", TextBox_HoverFontFamily.Text);
- sqlcom7.Parameters.AddWithValue("@Size", TextBox_Size.Text);
- sqlcom8.Parameters.AddWithValue("@Size_Hover", TextBox_HoverSize.Text);
- sqlcom9.Parameters.AddWithValue("@FontWeight", TextBox_FontWeight.Text);
- sqlcom10.Parameters.AddWithValue("@FontWeight_Hover", TextBox_HoverFontWeight.Text);
- sqlcom11.Parameters.AddWithValue("@Style", TextBox_Style.Text);
- sqlcom12.Parameters.AddWithValue("@Style_Hover", TextBox_HoverStyle.Text);
-
- sqlconn1.Open();
-
- sqlcom1.ExecuteNonQuery();
-
- sqlconn1.Close();
- }
Jeg har så lige lidt tidligere fået at vide jeg evt. kan lave det med en while lække i stedet for at gentage min sql command så mange gange. Men 1) Vil det få det til at virke? 2) Hvordan skal jeg gøre det??