Hiya,
I'm trying to replace the commented out code below with a neater
version using the IAttributeAcces sor interface (so that I don't have to
write 'if' statements for all control types).
At the moment this doen't work. The test line I put in
(string s = ControlAttribut es.string s = ControlAttribut es.GetAttribute
("Text");
is giving me s as null. Neither the GetAttribute nor the SetAttrubute
fail - they just don't seem to do anything.
Any clues what I'm doing wrong?
Kirsty
_______________ _______________ _____
public void SetCaptions
(
System.Web.UI.H tmlControls.Htm lForm WebForm,
System.Data.Dat aSet Captions
)
{
System.Data.Dat aTable CaptionDataTabl e = new System.Data.Dat aTable();
string ControlName = "";
string ControlText = "";
System.Web.UI.C ontrol Control;
// Get the captions data table from the dataset
CaptionDataTabl e = Captions.Tables[_CaptionDataTab leName];
// Go through the data, setting the Text property of each control
foreach (System.Data.Da taRow Row in CaptionDataTabl e.Rows)
{
ControlName = Row[_ControlNameFie ldName].ToString();
ControlText = Row[_ControlCaption FieldName].ToString();
Control = WebForm.FindCon trol (ControlName);
if (!(Control == null))
{
System.Web.UI.I AttributeAccess or ControlAttribut es =
(System.Web.UI. IAttributeAcces sor)Control;
string s = ControlAttribut es.GetAttribute ("Text");
ControlAttribut es.SetAttribute ("Text",Control Text);
// if (Control is System.Web.UI.W ebControls.Labe l)
// {
// System.Web.UI.W ebControls.Labe l Lbl =
(System.Web.UI. WebControls.Lab el)Control;
// Lbl.Text = ControlText;
// } // (ControlType is System.Web.UI.W ebControls.Labe l)
} //(!(Control ==null))
} //foreach
} //SetCaptions