Sunday, March 11, 2012

value for checkbox in an itemtemplate...

Make sure the cell index is correct and use

(CheckBox)e.Item.Cells[2].FindControl("cbxDelete")
okay, that's clear, many thanx!
but now i have another problem:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vbcon/html/vbtskpassingvaluesbetweenwebformspages.asp

this doesn't work, the page isn't found
here's my code:


public rsShowtable sourcePage;
protected System.Web.UI.WebControls.DataGrid dgridData;

private void Page_Load(object sender, System.EventArgs e)
{
if(!this.IsPostBack)
{
rsShowtable sourcePage = (rsShowtable)Context.Handler;
Response.Write("zu löschende Datensätze: " + sourcePage._checkBoxValues);
}
}

here's my property:


public string CheckBoxVals
{
set { _checkBoxValues = value; }
get { return _checkBoxValues; }
}

and here's my event-handler


private void lbDeleteSelection_Click(object sender, System.EventArgs e)
{
string checkVals = "";
foreach(DataGridItem i in dgridData.Items)
{
CheckBox chkSelected = (CheckBox)i.FindControl("cbxDelete");
if(chkSelected.Checked)
{
TextBox selID = (TextBox)i.FindControl("tbxRecID");
checkVals += selID.Text + ",";
}
}
this._checkBoxValues = checkVals;
Server.Transfer("rsDeleteSel.aspx?tn=" + tableName);
}

many thanx for your help!
atmosfear
should you not be using

Response.Write("zu löschende Datensätze: " + sourcePage.CheckBoxVals);

instead of

Response.Write("zu löschende Datensätze: " + sourcePage._checkBoxValues);

not quite sure where you are getting the error, let me know and I will try to help
it says that rsShowtable which is the name of the class from webform1 is not found...
you must use a property to get the values from one page to another so this is why i'm using _checkBoxValues (this is the property) instead of CheckBoxVals...

many thanx
atmosfear

No comments:

Post a Comment