hi
see below code:
<asp:Label ID="LblName" runat="server"></asp:Label>
using (SqlConnection conn = General.GetConnection())
{
using (SqlCommand _cmd = General.GetCommand("Downloadurl_insert", conn))
{
string ipAddress;
ipAddress = Request.ServerVariables["HTTP_X_FORWARDED_FOR"];
if (ipAddress == "" || ipAddress == null)
ipAddress = Request.ServerVariables["REMOTE_ADDR"];
conn.Open();
_cmd.Parameters.AddWithValue("@downloadTitle", LblName.Text);
_cmd.Parameters.AddWithValue("@url", "~/downloads/neda.rar")
_cmd.Parameters.AddWithValue("@DownloadToken", GetDownloadToken(10));
_cmd.Parameters.AddWithValue("@IpAddress", ipAddress);
_cmd.Parameters.AddWithValue("@Hits", "0");
_cmd.Parameters.AddWithValue("@Downloaded", "false");
_cmd.ExecuteNonQuery();
}
}
now I want put label in gridview:
<asp:TemplateField ItemStyle-Width="24px" ItemStyle-VerticalAlign="Middle">
<ItemTemplate>
<asp:Label ID="LblName" runat="server"></asp:Label>
</ItemTemplate>
</asp:TemplateField>
now I want put all data from gridview in database I mean how I can change below code :
_cmd.Parameters.AddWithValue("@downloadTitle", LblName.Text);
in below metod:
using (SqlConnection conn = General.GetConnection())
{
using (SqlCommand _cmd = General.GetCommand("Downloadurl_insert", conn))
{
string ipAddress;
ipAddress = Request.ServerVariables["HTTP_X_FORWARDED_FOR"];
if (ipAddress == "" || ipAddress == null)
ipAddress = Request.ServerVariables["REMOTE_ADDR"];
conn.Open();
_cmd.Parameters.AddWithValue("@downloadTitle", LblName.Text);
_cmd.Parameters.AddWithValue("@url", "~/downloads/neda.rar")
_cmd.Parameters.AddWithValue("@DownloadToken", GetDownloadToken(10));
_cmd.Parameters.AddWithValue("@IpAddress", ipAddress);
_cmd.Parameters.AddWithValue("@Hits", "0");
_cmd.Parameters.AddWithValue("@Downloaded", "false");
_cmd.ExecuteNonQuery();
}
}
that insert all data(lblname) from grid view in database:
best regards
neda