using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
using System.IO;
using System.Text;
public partial class _Default : System.Web.UI.Page
{
SqlDataAdapter da = new SqlDataAdapter();
DataTable dt = new DataTable();
SqlConnection con = new SqlConnection();
string strPath = string.Empty;
SqlCommand cmd = new SqlCommand();
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
SqlConnection con = new SqlConnection("Data Source=192.168.0.141;Initial Catalog=mis;Persist Security Info=True;User ID=sa;Password=ms");
con.Open();
cmd = new SqlCommand("usp_subbrokerMapping", con);
cmd.CommandType = CommandType.StoredProcedure;
cmd.CommandTimeout = 100000;
SqlDataAdapter da = new SqlDataAdapter(cmd);
cmd.Parameters.AddWithValue("@tag", SqlDbType.VarChar).Value = "1";
DataSet ds = new DataSet();
da.Fill(ds);
DataGrid1.DataSource = ds;
DataGrid1.DataBind();
con.Close();
DataGrid1.Visible = true;
Label1.Visible = true;
Label1.Text = "Data Displayed Successfully";
}
}
protected void DataGrid1_RowCommand(object sender, GridViewCommandEventArgs e)
{
}
protected void DataGrid1_RowDataBound(object sender, GridViewRowEventArgs e)
{
}
protected void btnsave_Click(object sender, EventArgs e)
{
SqlConnection con = new SqlConnection("Data Source=192.168.0.141;Initial Catalog=mis;Persist Security Info=True;User ID=sa;Password=ms");
con.Open();
int i = 0;
bool blnSelect = false;
foreach (GridViewRow row in DataGrid1.Rows)
{
CheckBox rb = (CheckBox)row.FindControl("RowSelector");
Label lbltagcode = (Label)row.FindControl("lbltagcode");
TextBox Rmcode = (TextBox)DataGrid1.FooterRow.FindControl("txtRmcode");
if (rb.Checked)
{
cmd = new SqlCommand("usp_subbrokerMapping", con);
cmd.CommandType = CommandType.StoredProcedure;
cmd.CommandTimeout = 100000;
SqlDataAdapter da = new SqlDataAdapter(cmd);
cmd.Parameters.AddWithValue("@Sub_code", SqlDbType.VarChar).Value = lbltagcode.Text.ToString().Trim();
cmd.Parameters.AddWithValue("@rm_code", SqlDbType.VarChar).Value = Rmcode.Text.ToString();
cmd.Parameters.AddWithValue("@tag", SqlDbType.VarChar).Value = "2";
cmd.ExecuteNonQuery();
Label1.Visible = true;
Label1.Text = "Data Inserted Successfully";
}
rb.Checked = false;
i++;
}
con.Close();
}
}