Jun 28, 2012, 7:38 PM
[CLOSED] Extra Parameters in Textfields
Hi,
I'm trying to create a dynamic form, which is working fine. The issue I'm having is correlating textbox.Text to the primary key it should be associated with. Is there a way to add a parameter to the textboxes during their creation so that it can have a primary key in it (besides generating ID's based on primary key)? Code below to illustrate the issue:
I'm trying to create a dynamic form, which is working fine. The issue I'm having is correlating textbox.Text to the primary key it should be associated with. Is there a way to add a parameter to the textboxes during their creation so that it can have a primary key in it (besides generating ID's based on primary key)? Code below to illustrate the issue:
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm11.aspx.cs" Inherits="WebApplication1.WebForm11" %>
<%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
<script runat="server">
public class SampleData
{
public int Id { get; set; }
public string Description { get; set; }
public string Value { get; set; }
}
List<SampleData> GetData()
{
var result = new List<SampleData>();
result.Add(new SampleData { Id = 1, Description = "Sample Field#1", Value = "sf1" });
result.Add(new SampleData { Id = 2, Description = "Sample Field#2", Value = "sf2" });
result.Add(new SampleData { Id = 3, Description = "Sample Field#3", Value = "sf3" });
result.Add(new SampleData { Id = 4, Description = "Sample Field#4", Value = "sf4" });
result.Add(new SampleData { Id = 5, Description = "Sample Field#5", Value = "sf5" });
return result;
}
protected void Page_Load(object sender, EventArgs e)
{
CreateFields();
}
protected void CreateFields()
{
List<SampleData> d = GetData();
foreach (var x in d)
{
var tf = new Ext.Net.TextField();
tf.Text = x.Value;
tf.FieldLabel = x.Description;
//Could use line below to mimick extra param requirement
tf.ID = "tf" + x.Id.ToString();
Panel1.Add(tf);
}
}
protected void click(object sender, DirectEventArgs e)
{
foreach (Ext.Net.TextField x in Panel1.Items)
{
var newText = x.Text;
//var Id = x.ExtraParams["id"];
}
}
</script>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<ext:ResourceManager ID="ResourceManager1" runat="server">
</ext:ResourceManager>
<form id="form1" runat="server">
<div>
<ext:Panel ID="Panel2" runat="server" Height="350">
<Items>
<ext:Panel ID="Panel1" runat="server" Height="300" Title="Title" />
<ext:Button ID="Button1" runat="server" Text="Submit">
<DirectEvents>
<Click OnEvent="click" />
</DirectEvents>
</ext:Button>
</Items>
</ext:Panel>
</div>
</form>
</body>
</html>
Last edited by Daniil; Jul 06, 2012 at 3:43 PM.
Reason: [CLOSED]