Click here to Skip to main content
15,897,891 members
Home / Discussions / ASP.NET
   

ASP.NET

 
AnswerRe: SqlConnection Error Pin
Tarakeshwar Reddy15-Jun-07 8:12
professionalTarakeshwar Reddy15-Jun-07 8:12 
Questionmoving files to UNC share Pin
Keith Andersch15-Jun-07 6:26
Keith Andersch15-Jun-07 6:26 
AnswerRe: moving files to UNC share Pin
Keith Andersch15-Jun-07 9:33
Keith Andersch15-Jun-07 9:33 
Questioncannot create activex component .. Pin
dhanis15-Jun-07 6:12
dhanis15-Jun-07 6:12 
QuestionGet Web Service URL Pin
mail57235215-Jun-07 5:55
mail57235215-Jun-07 5:55 
QuestionAvailablity Calendar Controls Needed Pin
Brendan Vogt15-Jun-07 4:43
Brendan Vogt15-Jun-07 4:43 
AnswerRe: Availablity Calendar Controls Needed Pin
nareshss15-Jun-07 21:04
nareshss15-Jun-07 21:04 
QuestionHELP Please!! Datagrid with update function!!!!! Pin
papy-boom15-Jun-07 4:20
papy-boom15-Jun-07 4:20 
Hi,
I'm trying to construct a datagrid dynamicly by reading properties from an Xml File.
so i've defined a template column so they fit the type of controls defined in the xml.
this is code wish define the template column
public class GenericItem : ITemplate
{
private readonly string column;
//private bool validate;
public GenericItem(string column)
{
this.column = column;
}
public void InstantiateIn(Control container)
{
Literal l = new Literal();
l.DataBinding += new EventHandler(this.BindData);
container.Controls.Add(l);
}
public void BindData(object sender, EventArgs e)
{
Literal l = (Literal)sender;
DataGridItem container = (DataGridItem)l.NamingContainer;
l.Text = ((DataRowView)container.DataItem)[column].ToString();

}
}
public class ValidateEditItem : ITemplate
{
private readonly string column;
public ValidateEditItem(string column)
{
this.column = column;
}
public void InstantiateIn(Control container)
{
TextBox tb = new TextBox();
tb.DataBinding += new EventHandler(this.BindData);
container.Controls.Add(tb);
tb.ID = column;
RequiredFieldValidator rfv = new RequiredFieldValidator();
rfv.Text = "please write!";
rfv.ControlToValidate = tb.ID;
rfv.Display = ValidatorDisplay.Dynamic;
rfv.ID = "validate" + tb.ID;
container.Controls.Add(rfv);
}
public void BindData(object sender, EventArgs e)
{
TextBox tb = (TextBox)sender;
DataGridItem container = (DataGridItem)tb.NamingContainer;
tb.Text = ((DataRowView)container.DataItem)[column].ToString();
}
}
public TemplateColumn DynamicColumns(string column, bool isEditable)
{
TemplateColumn genericcolumn = new TemplateColumn();
genericcolumn.HeaderText = column;
genericcolumn.ItemTemplate = new GenericItem(column);

if (isEditable)
{
genericcolumn.EditItemTemplate = new ValidateEditItem(column);
}

return genericcolumn;
}

and the way i contruct column is
if (Type != null)
{
//case of primary key
BoundColumn ColPk = new BoundColumn();
ColPk.DataField = c.ColumnName;
ColPk.SortExpression = c.ColumnName;
ColPk.ReadOnly = true;
Grid.Columns.Add(ColPk);
}else
{
//case of other column
TemplateColumn col;
col = DynamicColumns(c.ColumnName, true);
col.SortExpression = c.ColumnName;
Grid.Columns.Add(col);
}

so that I'm sure to make the primary Key not editable;
but the problem is how to retreive the primary key from datagrid
while it's in readOnly and I've want the value of this key to make Update
I've tried with two method

public void GridUpdate(Object sender, DataGridCommandEventArgs e)
{
//the first way
e.Item.FindControl("key").Text ;->it returns null ;
//the second way
grid.DataKeys[e.Item.ItemIndex];->the grid.Datakeys isempty
}
So I can't contruct the UpdateQuery
thank in advance for help


QuestionPage_Load calling Sub [modified] Pin
kallileo15-Jun-07 3:44
kallileo15-Jun-07 3:44 
AnswerRe: Page_Load calling Sub Pin
kubben15-Jun-07 3:49
kubben15-Jun-07 3:49 
GeneralRe: Page_Load calling Sub Pin
kallileo15-Jun-07 4:03
kallileo15-Jun-07 4:03 
GeneralRe: Page_Load calling Sub Pin
kubben15-Jun-07 4:15
kubben15-Jun-07 4:15 
GeneralRe: Page_Load calling Sub Pin
kallileo15-Jun-07 5:15
kallileo15-Jun-07 5:15 
GeneralRe: Page_Load calling Sub Pin
kubben15-Jun-07 5:19
kubben15-Jun-07 5:19 
GeneralRe: Page_Load calling Sub Pin
kallileo15-Jun-07 5:35
kallileo15-Jun-07 5:35 
QuestionHttpContext.Request.Url Problem Pin
Jkirt15-Jun-07 3:40
Jkirt15-Jun-07 3:40 
AnswerRe: HttpContext.Request.Url Problem Pin
kubben15-Jun-07 3:51
kubben15-Jun-07 3:51 
GeneralRe: HttpContext.Request.Url Problem Pin
Jkirt15-Jun-07 4:01
Jkirt15-Jun-07 4:01 
GeneralRe: HttpContext.Request.Url Problem Pin
kubben15-Jun-07 4:12
kubben15-Jun-07 4:12 
GeneralRe: HttpContext.Request.Url Problem Pin
Jkirt15-Jun-07 4:59
Jkirt15-Jun-07 4:59 
GeneralRe: HttpContext.Request.Url Problem Pin
kubben15-Jun-07 5:13
kubben15-Jun-07 5:13 
GeneralRe: HttpContext.Request.Url Problem Pin
Jkirt15-Jun-07 5:52
Jkirt15-Jun-07 5:52 
GeneralRe: HttpContext.Request.Url Problem Pin
kubben15-Jun-07 6:02
kubben15-Jun-07 6:02 
GeneralRe: HttpContext.Request.Url Problem Pin
Jkirt15-Jun-07 6:11
Jkirt15-Jun-07 6:11 
GeneralRe: HttpContext.Request.Url Problem Pin
kubben15-Jun-07 6:03
kubben15-Jun-07 6:03 

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.