| Module | Select |
|---|---|
| Home | |
| Abouts | |
| Career | |
| Contact |
Tail me friend how to insert multiple check checkbox value insert into database above fig databse have two field Module And Select how to insert selected colum Add Delete Updated View those are check is insert into database how my code is
Asp Code
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Home.aspx.cs" Inherits="Home" %>
<%--
--%>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;
public partial class Home : System.Web.UI.Page
{
SqlConnection con = new SqlConnection("Data Source=GANGESH-PC;Initial Catalog=ISB;User ID=sa;Password=sasa");
protected void Page_Load(object sender, EventArgs e)
{
string str = "select Module from Modules";
SqlCommand cmd = new SqlCommand(str,con);
SqlDataAdapter sda = new SqlDataAdapter(cmd);
DataSet ds = new DataSet();
sda.Fill(ds);
GridView1.DataSource = ds;
GridView1.DataBind();
}
protected void Button1_Click(object sender, EventArgs e)
{
string str = string.Empty;
string strname = string.Empty;
foreach (GridViewRow gvrow in GridView1.Rows)
{
CheckBox chk = (CheckBox)gvrow.FindControl("chkSelect");
if (chk != null & chk.Checked)
{
str += GridView1.DataKeys[gvrow.RowIndex].Value.ToString() + ',';
strname += gvrow.Cells[2].Text + ',';
}
}
}
}
Vithal WadjePosted Nov 2, 2014, 9:48 AM
http://www.c-sharpcorner.com/UploadFile/0c1bb2/insert-bulk-records-into-database-using-Asp-Net-C-Sharp/
Jaganathan BantheswaranPosted Nov 2, 2014, 5:33 AM
Pankaj KumarPosted Nov 2, 2014, 2:05 AM
Jaganathan BantheswaranPosted Nov 2, 2014, 1:43 AM
You have to redesign your DB so that your DB has a new Table called "ModuleActions" where you store moduleID, and add, delete, update and delete as a boolean columns.
While saving the table values insert the checked values with module id.