Click here to Skip to main content
15,887,302 members
Home / Discussions / C#
   

C#

 
AnswerRe: string to int in C#? Pin
leejo12310-Oct-05 3:16
leejo12310-Oct-05 3:16 
Questioncheckbox in datagrid Pin
ahager7-Oct-05 7:05
ahager7-Oct-05 7:05 
AnswerRe: checkbox in datagrid Pin
XRaheemX7-Oct-05 7:15
XRaheemX7-Oct-05 7:15 
GeneralRe: checkbox in datagrid Pin
ahager7-Oct-05 7:17
ahager7-Oct-05 7:17 
GeneralRe: checkbox in datagrid Pin
XRaheemX7-Oct-05 7:20
XRaheemX7-Oct-05 7:20 
GeneralRe: checkbox in datagrid Pin
ahager7-Oct-05 7:27
ahager7-Oct-05 7:27 
GeneralRe: checkbox in datagrid Pin
XRaheemX7-Oct-05 7:32
XRaheemX7-Oct-05 7:32 
GeneralRe: checkbox in datagrid Pin
ahager7-Oct-05 8:00
ahager7-Oct-05 8:00 
The autopostback did not work, as my textbox is in a template column in the datagrid, do I perform the following?

private void CheckBox1_CheckedChanged(object sender, System.EventArgs e)
{
DataGrid1.DataBind();
}

The checkbox is still showing as unchecked. Here is my complete code if this helps. Thanks!

using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
using System.Data.SqlTypes;
using System.Collections.Specialized;

namespace DeleteMergeSegments
{
///
/// Summary description for WebForm1.
///

public class WebForm1 : System.Web.UI.Page
{
protected System.Data.SqlClient.SqlDataAdapter sqlDataAdapter1;
protected System.Data.SqlClient.SqlCommand sqlSelectCommand1;
protected System.Data.SqlClient.SqlCommand sqlInsertCommand1;
protected System.Data.SqlClient.SqlCommand sqlUpdateCommand1;
protected System.Data.SqlClient.SqlCommand sqlDeleteCommand1;
protected System.Data.SqlClient.SqlConnection sqlConnection1;
protected DeleteMergeSegments.segmentDS segmentDS1;
protected System.Web.UI.WebControls.Button Delete;
protected System.Web.UI.WebControls.HyperLink HyperLink1;
protected System.Web.UI.WebControls.DataGrid DataGrid1;

private void Page_Load(object sender, System.EventArgs e)
{
sqlDataAdapter1.Fill(segmentDS1);
DataGrid1.DataBind();

int loop1;
// Load NameValueCollection object.
NameValueCollection coll=Request.QueryString;
// Get names of all keys into a string array.
String[] arr1 = coll.AllKeys;
for (loop1 = 0; loop1 < arr1.Length; loop1++)
{
String[] arr2 = coll.GetValues(arr1[loop1]);
}


}

#region Web Form Designer generated code
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: This call is required by the ASP.NET Web Form Designer.
//
InitializeComponent();
base.OnInit(e);
}

///
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
///

private void InitializeComponent()
{
this.sqlDataAdapter1 = new System.Data.SqlClient.SqlDataAdapter();
this.sqlDeleteCommand1 = new System.Data.SqlClient.SqlCommand();
this.sqlConnection1 = new System.Data.SqlClient.SqlConnection();
this.sqlInsertCommand1 = new System.Data.SqlClient.SqlCommand();
this.sqlSelectCommand1 = new System.Data.SqlClient.SqlCommand();
this.sqlUpdateCommand1 = new System.Data.SqlClient.SqlCommand();
this.segmentDS1 = new DeleteMergeSegments.segmentDS();
((System.ComponentModel.ISupportInitialize)(this.segmentDS1)).BeginInit();
this.DataGrid1.SelectedIndexChanged += new System.EventHandler(this.DataGrid1_SelectedIndexChanged);
this.Delete.Click += new System.EventHandler(this.Delete_Click);
//
// sqlDataAdapter1
//
this.sqlDataAdapter1.DeleteCommand = this.sqlDeleteCommand1;
this.sqlDataAdapter1.InsertCommand = this.sqlInsertCommand1;
this.sqlDataAdapter1.SelectCommand = this.sqlSelectCommand1;
this.sqlDataAdapter1.TableMappings.AddRange(new System.Data.Common.DataTableMapping[] {
new System.Data.Common.DataTableMapping("Table", "mergeSegment", new System.Data.Common.DataColumnMapping[] {
new System.Data.Common.DataColumnMapping("iQuoteId", "iQuoteId"),
new System.Data.Common.DataColumnMapping("siLineNumber", "siLineNumber"),
new System.Data.Common.DataColumnMapping("chSegmentDesc", "chSegmentDesc"),
new System.Data.Common.DataColumnMapping("iMergeSegmentQty", "iMergeSegmentQty")})});
this.sqlDataAdapter1.UpdateCommand = this.sqlUpdateCommand1;
//
// sqlDeleteCommand1
//
this.sqlDeleteCommand1.CommandText = @"DELETE FROM mergeSegment WHERE (iQuoteId = @Original_iQuoteId) AND (siLineNumber = @Original_siLineNumber) AND (chSegmentDesc = @Original_chSegmentDesc) AND (iMergeSegmentQty = @Original_iMergeSegmentQty OR @Original_iMergeSegmentQty IS NULL AND iMergeSegmentQty IS NULL)";
this.sqlDeleteCommand1.Connection = this.sqlConnection1;
this.sqlDeleteCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_iQuoteId", System.Data.SqlDbType.Int, 4, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "iQuoteId", System.Data.DataRowVersion.Original, null));
this.sqlDeleteCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_siLineNumber", System.Data.SqlDbType.SmallInt, 2, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "siLineNumber", System.Data.DataRowVersion.Original, null));
this.sqlDeleteCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_chSegmentDesc", System.Data.SqlDbType.VarChar, 75, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "chSegmentDesc", System.Data.DataRowVersion.Original, null));
this.sqlDeleteCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_iMergeSegmentQty", System.Data.SqlDbType.Int, 4, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "iMergeSegmentQty", System.Data.DataRowVersion.Original, null));
//
// sqlConnection1
//
this.sqlConnection1.ConnectionString = "workstation id=QED_IT4;packet size=4096;user id=sa;password=157m0nd0;data source=" +
"Production1;persist security info=False;initial catalog=laaf_o";
//
// sqlInsertCommand1
//
this.sqlInsertCommand1.CommandText = @"INSERT INTO mergeSegment(iQuoteId, siLineNumber, chSegmentDesc, iMergeSegmentQty) VALUES (@iQuoteId, @siLineNumber, @chSegmentDesc, @iMergeSegmentQty); SELECT iQuoteId, siLineNumber, chSegmentDesc, iMergeSegmentQty FROM mergeSegment WHERE (iQuoteId = @iQuoteId) AND (siLineNumber = @siLineNumber)";
this.sqlInsertCommand1.Connection = this.sqlConnection1;
this.sqlInsertCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@iQuoteId", System.Data.SqlDbType.Int, 4, "iQuoteId"));
this.sqlInsertCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@siLineNumber", System.Data.SqlDbType.SmallInt, 2, "siLineNumber"));
this.sqlInsertCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@chSegmentDesc", System.Data.SqlDbType.VarChar, 75, "chSegmentDesc"));
this.sqlInsertCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@iMergeSegmentQty", System.Data.SqlDbType.Int, 4, "iMergeSegmentQty"));
//
// sqlSelectCommand1
//
this.sqlSelectCommand1.CommandText = "SELECT iQuoteId, siLineNumber, chSegmentDesc, iMergeSegmentQty FROM mergeSegment " +
"WHERE (iQuoteId = 10153)";
this.sqlSelectCommand1.Connection = this.sqlConnection1;
//
// sqlUpdateCommand1
//
this.sqlUpdateCommand1.CommandText = @"UPDATE mergeSegment SET iQuoteId = @iQuoteId, siLineNumber = @siLineNumber, chSegmentDesc = @chSegmentDesc, iMergeSegmentQty = @iMergeSegmentQty WHERE (iQuoteId = @Original_iQuoteId) AND (siLineNumber = @Original_siLineNumber) AND (chSegmentDesc = @Original_chSegmentDesc) AND (iMergeSegmentQty = @Original_iMergeSegmentQty OR @Original_iMergeSegmentQty IS NULL AND iMergeSegmentQty IS NULL); SELECT iQuoteId, siLineNumber, chSegmentDesc, iMergeSegmentQty FROM mergeSegment WHERE (iQuoteId = @iQuoteId) AND (siLineNumber = @siLineNumber)";
this.sqlUpdateCommand1.Connection = this.sqlConnection1;
this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@iQuoteId", System.Data.SqlDbType.Int, 4, "iQuoteId"));
this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@siLineNumber", System.Data.SqlDbType.SmallInt, 2, "siLineNumber"));
this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@chSegmentDesc", System.Data.SqlDbType.VarChar, 75, "chSegmentDesc"));
this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@iMergeSegmentQty", System.Data.SqlDbType.Int, 4, "iMergeSegmentQty"));
this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_iQuoteId", System.Data.SqlDbType.Int, 4, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "iQuoteId", System.Data.DataRowVersion.Original, null));
this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_siLineNumber", System.Data.SqlDbType.SmallInt, 2, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "siLineNumber", System.Data.DataRowVersion.Original, null));
this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_chSegmentDesc", System.Data.SqlDbType.VarChar, 75, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "chSegmentDesc", System.Data.DataRowVersion.Original, null));
this.sqlUpdateCommand1.Parameters.Add(new System.Data.SqlClient.SqlParameter("@Original_iMergeSegmentQty", System.Data.SqlDbType.Int, 4, System.Data.ParameterDirection.Input, false, ((System.Byte)(0)), ((System.Byte)(0)), "iMergeSegmentQty", System.Data.DataRowVersion.Original, null));
//
// segmentDS1
//
this.segmentDS1.DataSetName = "segmentDS";
this.segmentDS1.Locale = new System.Globalization.CultureInfo("en-US");
this.Load += new System.EventHandler(this.Page_Load);
((System.ComponentModel.ISupportInitialize)(this.segmentDS1)).EndInit();

}
#endregion

private void Delete_Click(object sender, System.EventArgs e)
{
SqlConnection sc2 = new SqlConnection("workstation id=QED_IT4;packet size=4096;user id=sa;password=157m0nd0;data source=Production1;persist security info=False;initial catalog=laaf_l");
sc2.Open();
SqlCommand sCmd2 = sc2.CreateCommand();
SqlDataAdapter sda2 = new SqlDataAdapter();
sda2.DeleteCommand = sCmd2;

foreach(DataGridItem DataGridItem in DataGrid1.Items)
{
if(DataGridItem.Cells[0].Controls[0] is CheckBox)
{
CheckBox Checkbox1 = (CheckBox)DataGridItem.Cells[0].Controls[0];
if(Checkbox1.Checked == true)
{
sCmd2.CommandType=CommandType.Text;
sCmd2.CommandText = "del_merge_segment " + Request.QueryString.Get("iQuoteId") + "," + Request.QueryString.Get("txtLineNumber");
}
}

}
SqlCommand sCmd3=sc2.CreateCommand();
SqlDataAdapter sda3 = new SqlDataAdapter();
sda3.UpdateCommand = sCmd3;
sCmd3.CommandType = CommandType.Text;
sCmd3.CommandText ="resequence_merge_lines " + Request.QueryString.Get("iQuoteId");

}

AND HERE IS THE HTML:

<%@ Page language="c#" Codebehind="WebForm1.aspx.cs" AutoEventWireup="false" Inherits="DeleteMergeSegments.WebForm1" %>



<title>WebForm1







<asp:datagrid id="DataGrid1" style="Z-INDEX: 101; LEFT: 40px; POSITION: absolute; TOP: 72px" runat="server" width="880px" cellpadding="1" cellspacing="2" forecolor="Purple" backcolor="#D8D8E6" autogeneratecolumns="False" datamember="mergeSegment" datasource="<%# segmentDS1 %>" borderstyle="Solid" bordercolor="White">
<selecteditemstyle horizontalalign="Center" forecolor="Indigo" verticalalign="Middle" backcolor="#D8D8E6">
<edititemstyle horizontalalign="Center" forecolor="Indigo" verticalalign="Middle" backcolor="#D8D8E6">
<alternatingitemstyle horizontalalign="Center" forecolor="Indigo" verticalalign="Middle" backcolor="#D8D8E6">
<itemstyle horizontalalign="Center" forecolor="Indigo" verticalalign="Middle" backcolor="#D8D8E6">
<headerstyle horizontalalign="Center" forecolor="White" verticalalign="Middle" backcolor="DarkSlateBlue">
<columns>
<asp:templatecolumn sortexpression="siLineNumber" headertext="Delete">
<headerstyle horizontalalign="Center" forecolor="White" verticalalign="Middle" backcolor="DarkSlateBlue">
<itemstyle horizontalalign="Center" verticalalign="Middle" backcolor="#D8D8E6">
<itemtemplate>
 
<asp:checkbox id="CheckBox1" runat="server">


<asp:boundcolumn datafield="iQuoteId" sortexpression="iQuoteId" headertext="iQuoteId">
<headerstyle horizontalalign="Center" verticalalign="Middle">
<itemstyle horizontalalign="Center" verticalalign="Middle">

<asp:boundcolumn datafield="siLineNumber" sortexpression="siLineNumber" headertext="siLineNumber">
<headerstyle horizontalalign="Center" verticalalign="Middle">
<itemstyle horizontalalign="Center" verticalalign="Middle">

<asp:boundcolumn datafield="chSegmentDesc" sortexpression="chSegmentDesc" headertext="chSegmentDesc">
<headerstyle horizontalalign="Center" verticalalign="Middle">
<itemstyle horizontalalign="Center" verticalalign="Middle">

<asp:boundcolumn datafield="iMergeSegmentQty" sortexpression="iMergeSegmentQty" headertext="iMergeSegmentQty">
<headerstyle horizontalalign="Center" verticalalign="Middle">
<itemstyle horizontalalign="Center" verticalalign="Middle">


<asp:button id="Delete" style="Z-INDEX: 102; LEFT: 48px; POSITION: absolute; TOP: 32px" runat="server"
="" text="Delete"><asp:hyperlink id="HyperLink1" style="Z-INDEX: 103; LEFT: 832px; POSITION: absolute; TOP: 40px"
="" runat="server" navigateurl="ViewMergeSegments.asp">return


GeneralRe: checkbox in datagrid Pin
XRaheemX7-Oct-05 8:15
XRaheemX7-Oct-05 8:15 
QuestionOut Of MEmory Pin
Greeky7-Oct-05 6:48
Greeky7-Oct-05 6:48 
AnswerRe: Out Of MEmory Pin
XRaheemX7-Oct-05 6:57
XRaheemX7-Oct-05 6:57 
GeneralRe: Out Of MEmory Pin
Greeky7-Oct-05 7:31
Greeky7-Oct-05 7:31 
GeneralRe: Out Of MEmory Pin
Tom Larsen7-Oct-05 7:37
Tom Larsen7-Oct-05 7:37 
GeneralRe: Out Of MEmory Pin
XRaheemX7-Oct-05 7:39
XRaheemX7-Oct-05 7:39 
QuestionCursor position Pin
Agyeman7-Oct-05 6:33
Agyeman7-Oct-05 6:33 
AnswerRe: Cursor position Pin
Daniel Grunwald7-Oct-05 6:38
Daniel Grunwald7-Oct-05 6:38 
GeneralRe: Cursor position Pin
XRaheemX7-Oct-05 7:00
XRaheemX7-Oct-05 7:00 
GeneralRe: Cursor position Pin
Agyeman7-Oct-05 8:28
Agyeman7-Oct-05 8:28 
GeneralRe: Cursor position Pin
XRaheemX7-Oct-05 8:47
XRaheemX7-Oct-05 8:47 
GeneralRe: Cursor position Pin
Agyeman7-Oct-05 9:01
Agyeman7-Oct-05 9:01 
GeneralRe: Cursor position Pin
XRaheemX7-Oct-05 9:05
XRaheemX7-Oct-05 9:05 
GeneralRe: Cursor position Pin
XRaheemX7-Oct-05 9:06
XRaheemX7-Oct-05 9:06 
GeneralRe: Cursor position Pin
Agyeman7-Oct-05 9:11
Agyeman7-Oct-05 9:11 
GeneralRe: Cursor position Pin
XRaheemX7-Oct-05 9:13
XRaheemX7-Oct-05 9:13 
GeneralRe: Cursor position Pin
Agyeman7-Oct-05 9:28
Agyeman7-Oct-05 9:28 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.