B
Babu Mannaravalappil
Hi,
I have a radio button group which I want to bind to a table column whose
value is a string. Based on the string value, I want to checkmark one of
the radio buttons. Here is my code in an attempt to do this. But it fails.
The events don't even fire. I don't know what I am missing. All other
databindings (to text boxes and combo boxes even check boxes) seem to work
fine. But then, those controls don't need datatype conversion either. Can
somebody please help?
CatalogsDV is a Dataview of my datasource. And I have a currencyManager that
positions the data. I have no problems there since other controls seem to
work.
Binding b2b = new Binding("Checked", catalogsDV, Const.CATALOGTYPECOLUMN);
b2b.Format += new ConvertEventHandler(FormatCatalogType);
b2b.Parse += new ConvertEventHandler(ParseCatalogType);
this.rdbtnB2B.DataBindings.Add(b2b);
//
//
//
//
private void FormatCatalogType(object sender, ConvertEventArgs e)
{
if (e.DesiredType != typeof(string)) return;
string ctype = (string)e.Value;
if (ctype == "B2B")
this.rdbtnB2B.Checked = true;
else if (ctype == "B2C")
this.rdbtnB2C.Checked = true;
}
private void ParseCatalogType(object sender, ConvertEventArgs e)
{
if (e.DesiredType != typeof(bool)) return;
bool ctype = (bool)e.Value;
if (ctype == true)
e.Value = "B2B";
else if (ctype == false)
e.Value = "B2C";
}
I am confused with the complexity of Databinding. But trying to learn. I
assume the above event methods are correct, at least logically. I have
placed breakpoints inside both the above events. But they don't seem to
fire at all. Can somebody please help?
Babu.
I have a radio button group which I want to bind to a table column whose
value is a string. Based on the string value, I want to checkmark one of
the radio buttons. Here is my code in an attempt to do this. But it fails.
The events don't even fire. I don't know what I am missing. All other
databindings (to text boxes and combo boxes even check boxes) seem to work
fine. But then, those controls don't need datatype conversion either. Can
somebody please help?
CatalogsDV is a Dataview of my datasource. And I have a currencyManager that
positions the data. I have no problems there since other controls seem to
work.
Binding b2b = new Binding("Checked", catalogsDV, Const.CATALOGTYPECOLUMN);
b2b.Format += new ConvertEventHandler(FormatCatalogType);
b2b.Parse += new ConvertEventHandler(ParseCatalogType);
this.rdbtnB2B.DataBindings.Add(b2b);
//
//
//
//
private void FormatCatalogType(object sender, ConvertEventArgs e)
{
if (e.DesiredType != typeof(string)) return;
string ctype = (string)e.Value;
if (ctype == "B2B")
this.rdbtnB2B.Checked = true;
else if (ctype == "B2C")
this.rdbtnB2C.Checked = true;
}
private void ParseCatalogType(object sender, ConvertEventArgs e)
{
if (e.DesiredType != typeof(bool)) return;
bool ctype = (bool)e.Value;
if (ctype == true)
e.Value = "B2B";
else if (ctype == false)
e.Value = "B2C";
}
I am confused with the complexity of Databinding. But trying to learn. I
assume the above event methods are correct, at least logically. I have
placed breakpoints inside both the above events. But they don't seem to
fire at all. Can somebody please help?
Babu.