- using System;
-
using System.Collections;
-
using System.ComponentModel;
-
using System.Security.Permissions;
-
using System.Web;
-
using System.Web.UI;
-
using System.Web.UI.WebControls;
-
-
namespace Samples.AspNet.Controls.CS {
-
-
[AspNetHostingPermission(SecurityAction.Demand,
-
Level=AspNetHostingPermissionLevel.Minimal)]
-
[AspNetHostingPermission(SecurityAction.InheritanceDemand,
-
Level=AspNetHostingPermissionLevel.Minimal)]
-
public class TextBoxSet : DataBoundControl {
-
-
private IList alBoxSet;
-
public IList BoxSet {
-
get {
-
if (null == alBoxSet) {
-
alBoxSet = new ArrayList();
-
}
-
return alBoxSet;
-
}
-
}
-
public string DataTextField {
-
get {
-
object o = ViewState["DataTextField"];
-
return((o == null) ? string.Empty : (string)o);
-
}
-
set {
-
ViewState["DataTextField"] = value;
-
if (Initialized) {
-
OnDataPropertyChanged();
-
}
-
}
-
}
-
protected override void PerformSelect() {
-
-
// Call OnDataBinding here if bound to a data source using the
-
// DataSource property (instead of a DataSourceID), because the
-
// databinding statement is evaluated before the call to GetData.
-
if (! IsBoundUsingDataSourceID) {
-
OnDataBinding(EventArgs.Empty);
-
}
-
-
// The GetData method retrieves the DataSourceView object from
-
// the IDataSource associated with the data-bound control.
-
GetData().Select(CreateDataSourceSelectArguments(),
-
OnDataSourceViewSelectCallback);
-
-
// The PerformDataBinding method has completed.
-
RequiresDataBinding = false;
-
MarkAsDataBound();
-
-
// Raise the DataBound event.
-
OnDataBound(EventArgs.Empty);
-
}
-
private void OnDataSourceViewSelectCallback(IEnumerable retrievedData) {
-
-
// Call OnDataBinding only if it has not already been
-
// called in the PerformSelect method.
-
if (IsBoundUsingDataSourceID) {
-
OnDataBinding(EventArgs.Empty);
-
}
-
// The PerformDataBinding method binds the data in the
-
// retrievedData collection to elements of the data-bound control.
-
PerformDataBinding(retrievedData);
-
}
-
protected override void PerformDataBinding(IEnumerable retrievedData) {
-
base.PerformDataBinding(retrievedData);
-
-
// If the data is retrieved from an IDataSource as an
-
// IEnumerable collection, attempt to bind its values to a
-
// set of TextBox controls.
-
if (retrievedData != null) {
-
-
foreach (object dataItem in retrievedData) {
-
-
TextBox box = new TextBox();
-
-
// The dataItem is not just a string, but potentially
-
// a System.Data.DataRowView or some other container.
-
// If DataTextField is set, use it to determine which
-
// field to render. Otherwise, use the first field.
-
if (DataTextField.Length > 0) {
-
box.Text = DataBinder.GetPropertyValue(dataItem,
-
DataTextField, null);
-
}
-
else {
-
PropertyDescriptorCollection props =
-
TypeDescriptor.GetProperties(dataItem);
-
-
// Set the "default" value of the TextBox.
-
box.Text = String.Empty;
-
-
// Set the true data-bound value of the TextBox,
-
// if possible.
-
if (props.Count >= 1) {
-
if (null != props[0].GetValue(dataItem)) {
-
box.Text = props[0].GetValue(dataItem).ToString();
-
}
-
}
-
}
-
-
BoxSet.Add(box);
-
}
-
}
-
}
-
protected override void Render(HtmlTextWriter writer) {
-
-
// Render nothing if the control is empty.
-
if (BoxSet.Count <= 0) {
-
return;
-
}
-
-
// Make sure the control is declared in a form tag
-
// with runat=server.
-
if (Page != null) {
-
Page.VerifyRenderingInServerForm(this);
-
}
-
-
// For this example, render the BoxSet as
-
// an unordered list of TextBox controls.
-
writer.RenderBeginTag(HtmlTextWriterTag.Ul);
-
-
foreach (object item in BoxSet) {
-
-
TextBox box = (TextBox) item;
-
-
// Write each element as
-
// <li><input type="text" value="string"><input/></li>
-
-
writer.WriteBeginTag("li");
-
writer.Write(">");
-
writer.WriteBeginTag("input");
-
writer.WriteAttribute("type", "text");
-
writer.WriteAttribute("value", box.Text);
-
writer.Write(">");
-
writer.WriteEndTag("input");
-
writer.WriteEndTag("li");
-
}
-
-
writer.RenderEndTag();
-
}
-
}
1 1382
What is your question? You can't just dump a block of code on us and expect us to tell you what to do with it.
Be very specific in your explanation.
Also, you need to use [code] tags when you post code.
MODERATOR
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Sowen |
last post by:
Hi, all
I am wondering how to write bits by using ofstream?
I have finished a huffman tree, but how can I write the bits to the file in
order to gain compression?
for example, 'A' returns a code '1101', what I should write? 13? no, I don't
think so
|
by: Magix |
last post by:
Hi,
I have these string data: str_data1, str_data2, str_data3, which capture
some value after a routine process A. Then I would like to write (append)
these 3 string values into a text file each time after routine process A,
the text file is named "mytext.dat" in following format with "#####" as
separator.
The maximum entries of them is 5. When reaching the fifth entry, it will
delete the very first entry.
|
by: wiso |
last post by:
My problem is this (from:
http://www.cplusplus.com/ref/iostream/fstream/open.html)
#include <fstream>
using namespace std;
int main()
{
fstream f;
|
by: Buddy Home |
last post by:
Hello,
I'm trying to upload a file programatically and occasionally I get the
following error message.
Unable to write data to the transport connection: An established connection
was aborted by the software in your host machine.
Stack Trace
at System.Net.Sockets.NetworkStream.Write(Byte buffer, Int32 offset, Int32
|
by: Buddy Home |
last post by:
Hello,
I'm trying to upload a file programatically and occasionally I get the
following error message.
Unable to write data to the transport connection: An established connection
was aborted by the software in your host machine.
Stack Trace
at System.Net.Sockets.NetworkStream.Write(Byte buffer, Int32 offset, Int32
| |
by: aagarwal8 |
last post by:
Hi,
I am trying to write the contents of a textbox to a file in binary
format. My code looks like this...
private void btnWriteToFile_Click(object sender, EventArgs e)
{
FileStream fs = File.Open(@"D:\test.dat",
FileMode.OpenOrCreate, FileAccess.Write);
BinaryWriter bw = new BinaryWriter(fs);
|
by: Sachin Garg |
last post by:
I have a program which opens a fstream in binary input+output mode, creating
the file if it doesn't exists. But writing doesn't works after reading, it
must be something obvious that I am not aware of.
f.open(filename,ios::in | ios::out | ios::binary | ios::trunc)
The program flow is
1) write some data
2) read the data
|
by: sivakrishna546 |
last post by:
hi all
i am new to asp.net.
i dont know whre to write a code for a new namespace?
i want declare a new namespace n use it in another program?
can anybody tell me .
|
by: blazedaces |
last post by:
So I have a program below which writes an excel file with multiple sheets based on inputs of sheet names, data, cell types, etc. It uses Apache POI, which is currently the only thing I found (correct me if I'm wrong about this) that can write excel 2007 files. The program works. I've tested it out on very small files (I will include the commented out main method that you can use to test this out yourself if you'd like, that is assuming you...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |