The labels are temporary storage locations and therefore you have to give the same number of Labels as that of the columns.Here I use 6 Labels since I had 6 columns.
Now at the code behind section give the following code.
protected void SubmitSelection(object sender, DirectEventArgs e) { string json = e.ExtraParams["Values"]; Dictionary<string, string>[] companies = JSON.Deserialize<Dictionary<string, string>[]>(json); foreach (Dictionary<string, string> row in companies) { int i = 1; StringBuilder sb = new StringBuilder(); StringBuilder sb1 = new StringBuilder(); StringBuilder sb2 = new StringBuilder(); StringBuilder sb3 = new StringBuilder(); StringBuilder sb4 = new StringBuilder(); StringBuilder sb5 = new StringBuilder(); foreach (KeyValuePair<string, string> keyValuePair in row) { if (i == 1) { sb.Append(keyValuePair.Value); } else if (i == 2) sb1.Append(keyValuePair.Value); else if (i == 3) sb2.Append(keyValuePair.Value); else if (i == 4) sb3.Append(keyValuePair.Value); else if (i == 5) sb4.Append(keyValuePair.Value); else if(i == 6) sb5.Append(keyValuePair.Value); i++; } this.Label1.Text = sb.ToString(); this.Label2.Text = sb1.ToString(); this.Label3.Text = sb2.ToString(); this.Label4.Text = sb3.ToString(); this.Label5.Text = sb4.ToString(); this.Label6.Text = sb5.ToString(); SqlConnection con = new SqlConnection("YOUR CONNECTIONSTRING"); string query = "insert into tablename 0values ('" + Label1.Text + "','" + Label2.Text + "','" + Label3.Text + "','" + Label4.Text + "','" + Label5.Text + "','" + Label6.Text + "')"; SqlCommand cmd = new SqlCommand(query, con); con.Open(); cmd.ExecuteNonQuery(); con.Close(); }
In this the 'i' value represents the number of columns.
Technology Related Tips,Tricks,Software Solutions,Codes,Notes,Mg University >>>>> Download Now
ReplyDelete>>>>> Download Full
Technology Related Tips,Tricks,Software Solutions,Codes,Notes,Mg University >>>>> Download LINK
>>>>> Download Now
Technology Related Tips,Tricks,Software Solutions,Codes,Notes,Mg University >>>>> Download Full
>>>>> Download LINK