I have dynamic grid row textboxes, i add values and save, it gets serialized into json format and gets saved in database, now when i have to populate the grid(when i refresh)the saved data needs to be displayed on the textboxes. My code:
foreach (GridViewRow row in gv.Rows)
{
TextBox txtKey = (TextBox)e.Row.FindControl("txtKey");
TextBox txtValue = ((TextBox)row.FindControl("txtValue");
string JsonDeserialize = dtTerminalLocalConfig.Rows[0]["Settings"].ToString();
List<KeyValuePair<string, string>> configurations = new List<KeyValuePair<string, string>>();
configurations = JsonConvert.DeserializeObject<List<KeyValuePair<string, string>>>(JsonDeserialize);
configurations.Add(new KeyValuePair<string, string>(txtKey.Text, txtValue.text));
txtKey.Text = configurations.SingleOrDefault(K => K.Key == LocalConfigurations.Key).Value;
txtValue.Text = configurations.SingleOrDefault(K => K.Key == LocalConfigurations.Value).Value;
}
The 'configuration' has deserialized json strings and is assigned to txtboxes, but the textbox are giving null when debugged