Scenario:
I have a mobile phone comparing an asp.net website that displays transactions of various networks. The data on the transactions that we receive from the networks are in the excel sheet. We import data from excel sheets into tables of each network in our database. Now the data that we receive is incompatible for each network, since the network may indicate the name of the phone as "curve 8250", and the other may indicate it as "curve 8250", and the other may give it "8250curve".
Now we have another module that allows the user to view the transactions of a specific phone, available on all networks. For this module to work, we need to make an identifier so that the phone names are consistent for all networks.
To do this, I plan to create a module for webadmin that displays phone names (possibly in gridview) from all network tables, and the webmaster can edit phone names to make them consistent. Finding individual column names from all tables was simple, and it was done.
Problem:
Now the real part is how we can program the module so that it updates the values โโof specific columns in all network tables. The layout of each table is exactly the same.
Edit: I always forget to add something: @. I know this can be done in a complicated way, in the code behind, by running a loop. But is there an easier, useless way? like some datacontrol that will make life easier in this situation?
Update:
I tried to do this using code. I did a gridview and displayed the data using element templates, and also provided a text box in the second template. Then when I click the button, I run this code:
protected void Button1_Click(object sender, EventArgs e)
{
SqlConnection con = new SqlConnection(ConfigurationSettings.AppSettings[0].ToString());
foreach(GridViewRow gvr in GridView1.Rows)
{
TextBox tb = (TextBox)gvr.FindControl("New Value");
Label lbl = (Label)gvr.FindControl("Old Value");
SqlCommand cmd = new SqlCommand();
cmd.Connection = con;
if (lbl.Text != tb.Text)
{
try
{
con.Open();
cmd.CommandText = myupdatecommand;
cmd.ExecuteNonQuery();
}
catch (SqlException sqe)
{
if (sqe.ErrorCode == -2146232060)
{
try
{
cmd.CommandText = deletecommand;
cmd.ExecuteNonQuery();
}
catch { }
}
}
finally
{
con.Close();
}
try
{
con.Open();
cmd.CommandText = updatetable2;
cmd.ExecuteNonQuery();
}
catch
{
}
finally
{
con.Close();
}
.
.
.
.
.
.
Response.Redirect(Request.Url.ToString());
}
}
When I run this code, everything goes smoothly, but when we update more than one row in the grid at a time, the update only happens for the first edited row, the rest of the edited rows remain the same.
I know that this is a very small thing that I am missing here, but I can not continue further :(
. !
PS - ASP.Net 3.5 # SQL Server 2005 .