Click here to Skip to main content
15,890,512 members
Home / Discussions / ASP.NET
   

ASP.NET

 
AnswerRe: Regular Expression for link in vb.net label. Pin
Not Active18-Apr-10 15:16
mentorNot Active18-Apr-10 15:16 
AnswerRe: Regular Expression for link in vb.net label. Pin
Member 412548018-Apr-10 17:26
Member 412548018-Apr-10 17:26 
QuestionHow to check email existence with asp.net Pin
Shahriar Iqbal Chowdhury/Galib18-Apr-10 9:15
professionalShahriar Iqbal Chowdhury/Galib18-Apr-10 9:15 
AnswerRe: How to check email existence with asp.net Pin
Not Active18-Apr-10 11:44
mentorNot Active18-Apr-10 11:44 
Questiontransferring files Pin
leone18-Apr-10 8:44
leone18-Apr-10 8:44 
AnswerRe: transferring files Pin
michaelschmitt18-Apr-10 10:42
michaelschmitt18-Apr-10 10:42 
AnswerRe: transferring files Pin
Michel Godfroid18-Apr-10 19:46
Michel Godfroid18-Apr-10 19:46 
QuestionRadGrid keeping textboxes in sync with bounddata column? Pin
Steve Holdorf18-Apr-10 8:27
Steve Holdorf18-Apr-10 8:27 
I am using a radGrid which automatically sorts the bound columns; however, the griv also contains textbox columns which get out of sync once the bound columns are sorted. Can anyone help me with this? code below:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Telerik.WebControls;
using System.Collections;
using System.Data;

public partial class _Default : System.Web.UI.Page
{
protected RadGrid grid;
protected static ArrayList list = new ArrayList();

override protected void OnInit(EventArgs e)
{
DefineGridStructure();
base.OnInit(e);
}
private void DefineGridStructure()
{
this.grid = new RadGrid();
this.grid.AutoGenerateColumns = false;
this.grid.NeedDataSource += new GridNeedDataSourceEventHandler(OnNeedDataSource);
// this.grid.Page = this;
this.grid.AllowPaging = true;
this.grid.AllowSorting = true;
this.grid.PageSize = 4;
this.grid.Width = 650;



//other columns definitions ----------------------------

string templateColumnName = "TextBox Column 1";
GridTemplateColumn templateColumn = new GridTemplateColumn();
templateColumn.ItemTemplate = new MyTemplate(templateColumnName);
templateColumn.HeaderText = templateColumnName;
templateColumn.HeaderStyle.Width = 300;

string templateColumnName3 = "TextBox Column 2";
GridTemplateColumn templateColumn3 = new GridTemplateColumn();
templateColumn3.ItemTemplate = new MyTemplate3(templateColumnName3);
templateColumn3.HeaderText = templateColumnName3;
templateColumn3.HeaderStyle.Width = 300;


GridBoundColumn boundColumn1 = new GridBoundColumn();
boundColumn1.DataField = "B";
boundColumn1.UniqueName = "ConactName2";
boundColumn1.HeaderText = "Bound Column";
boundColumn1.HeaderStyle.Width = 300;

string templateColumnName2 = "Dropdown List Column";
GridTemplateColumn templateColumn2 = new GridTemplateColumn();
templateColumn2.ItemTemplate = new MyTemplate2(templateColumnName2);
templateColumn2.HeaderText = templateColumnName2;
templateColumn2.HeaderStyle.Width = 300;

this.grid.MasterTableView.Columns.Add(templateColumn);
this.grid.MasterTableView.Columns.Add(templateColumn2);
this.grid.MasterTableView.Columns.Add(boundColumn1);
this.grid.MasterTableView.Columns.Add(templateColumn3);
grid.AllowPaging = true;
grid.PageSize = 5;
grid.ClientSettings.Scrolling.AllowScroll = true;
grid.ClientSettings.Scrolling.ScrollHeight = 230;
grid.ClientSettings.Scrolling.ScrollWidth = 1200;
this.PlaceHolder1.Controls.Add(grid);
}

protected void grid_NeedDataSource(object source, Telerik.WebControls.GridNeedDataSourceEventArgs e)
{
this.grid.DataSource = list;
}

protected void Page_Load(object sender, EventArgs e)
{
ArrayList alist = new ArrayList();
list = new ArrayList();
alist.Add("1");
alist.Add("2");
list.Add( new TestListItem( "ItemA 0", "ItemB a", "ItemC a", alist ));
list.Add( new TestListItem( "ItemA 1", "ItemB b", "ItemC b", alist ));
list.Add( new TestListItem( "ItemA 2", "ItemB c", "ItemC c", alist ));
list.Add( new TestListItem( "ItemA 3", "ItemB d", "ItemC d", alist ));
list.Add( new TestListItem( "ItemA 4", "ItemB e", "ItemC e", alist ));
list.Add( new TestListItem( "ItemA 5", "ItemB f", "ItemC f", alist ));


}

private class MyTemplate : ITemplate
{
protected TextBox textBox1;

static int i;

private string colname;

public MyTemplate(string cName)
{
colname = cName;
}

public void InstantiateIn(System.Web.UI.Control container)
{

textBox1 = new TextBox();
textBox1.ID = "templateColumnTextBox";
textBox1.DataBinding += new EventHandler (this.BindTextBox1);

container.Controls.Add(textBox1);


}

void BindTextBox1(object sender, EventArgs e)
{
if (i >= list.Count)
i = 0;

if ( i < list.Count)
{
((TextBox)sender).Text = ((TestListItem)list[i]).A;
i++;
}
}
}

private class MyTemplate2 : ITemplate
{
protected DropDownList ddlValue;

private string colname;

public MyTemplate2(string cName)
{
colname = cName;
}

public void InstantiateIn(System.Web.UI.Control container)
{

ddlValue = new DropDownList();
ddlValue.ID = "templateColumnDropDownList";
ddlValue.CssClass = "DropDownList";
ddlValue.DataBinding += new EventHandler (this.BindDropDownList);


container.Controls.Add(ddlValue);


}


void BindDropDownList(object sender, EventArgs e)
{
((DropDownList)sender).DataSource = ((TestListItem)list[0]).AList;
}

}

private class MyTemplate3 : ITemplate
{
protected TextBox textBox3;

static int i;

private string colname;

public MyTemplate3(string cName)
{
colname = cName;
}

public void InstantiateIn(System.Web.UI.Control container)
{
textBox3 = new TextBox();
textBox3.ID = "templateColumnTextBox3";
textBox3.DataBinding += new EventHandler (this.BindTextBox3);
container.Controls.Add(textBox3);


}

void BindTextBox3(object sender, EventArgs e)
{
if (i >= list.Count)
i = 0;

if ( i < list.Count)
{
((TextBox)sender).Text = ((TestListItem)list[i]).C;
i++;
}
}
}


void OnNeedDataSource(object source, GridNeedDataSourceEventArgs e)
{
grid.DataSource = list;
}

public class TestListItem
{
private string _a;
private string _b;
private string _c;
ArrayList _aList;

public TestListItem( string a, string b, string c, ArrayList aList )
{
this._a = a;
this._b = b;
this._c = c;
this._aList = aList;
}

public string A
{
get
{
return this._a;
}
set
{
this._a = value;
}
}



public string B
{
get
{
return this._b;
}

set
{
this._b = value;
}

}

public string C
{
get
{
return this._c;
}

set
{
this._c = value;
}

}

public ArrayList AList
{
get
{
return this._aList;
}
set
{
this._aList = value;
}
}
}
}
AnswerRe: RadGrid keeping textboxes in sync with bounddata column? Pin
daveyerwin18-Apr-10 8:35
daveyerwin18-Apr-10 8:35 
GeneralRe: RadGrid keeping textboxes in sync with bounddata column? Pin
Steve Holdorf18-Apr-10 9:13
Steve Holdorf18-Apr-10 9:13 
GeneralRe: RadGrid keeping textboxes in sync with bounddata column? Pin
daveyerwin18-Apr-10 12:49
daveyerwin18-Apr-10 12:49 
GeneralRe: RadGrid keeping textboxes in sync with bounddata column? Pin
Steve Holdorf18-Apr-10 13:15
Steve Holdorf18-Apr-10 13:15 
QuestionCan I Bind method to the control? Pin
marijus518-Apr-10 5:34
marijus518-Apr-10 5:34 
AnswerRe: Can I Bind method to the control? Pin
Brij18-Apr-10 6:20
mentorBrij18-Apr-10 6:20 
GeneralRe: Can I Bind method to the control? Pin
marijus518-Apr-10 7:18
marijus518-Apr-10 7:18 
GeneralRe: Can I Bind method to the control? Pin
Brij18-Apr-10 7:58
mentorBrij18-Apr-10 7:58 
QuestionIssue with WebToolBox.DatePicker... Pin
<<Tash18>>18-Apr-10 3:39
<<Tash18>>18-Apr-10 3:39 
AnswerRe: Issue with WebToolBox.DatePicker... Pin
Sandeep Mewara18-Apr-10 5:26
mveSandeep Mewara18-Apr-10 5:26 
QuestionForcing full postback in UpdatePanel Pin
paper6718-Apr-10 3:04
paper6718-Apr-10 3:04 
AnswerRe: Forcing full postback in UpdatePanel [modified] Pin
daveyerwin18-Apr-10 4:42
daveyerwin18-Apr-10 4:42 
GeneralRe: Forcing full postback in UpdatePanel Pin
paper6718-Apr-10 8:57
paper6718-Apr-10 8:57 
GeneralRe: Forcing full postback in UpdatePanel Pin
daveyerwin18-Apr-10 12:11
daveyerwin18-Apr-10 12:11 
QuestionInvalid column names in asp.net application with sql server Pin
Lessobvious18-Apr-10 0:48
Lessobvious18-Apr-10 0:48 
AnswerRe: Invalid column names in asp.net application with sql server Pin
Not Active18-Apr-10 1:07
mentorNot Active18-Apr-10 1:07 
GeneralRe: Invalid column names in asp.net application with sql server Pin
Lessobvious18-Apr-10 2:35
Lessobvious18-Apr-10 2:35 

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.