本文整理汇总了C#中System.Web.UI.WebControls.RadioButtonList.DataBind方法的典型用法代码示例。如果您正苦于以下问题:C# RadioButtonList.DataBind方法的具体用法?C# RadioButtonList.DataBind怎么用?C# RadioButtonList.DataBind使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Web.UI.WebControls.RadioButtonList
的用法示例。
在下文中一共展示了RadioButtonList.DataBind方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: LlenarRadioBL_Web
public bool LlenarRadioBL_Web( RadioButtonList Generico )
{
if ( ! Validar() )
return false;
clsConexionBD objConexionBd = new clsConexionBD( strApp );
try
{
objConexionBd.SQL = strSQL;
if ( ! objConexionBd.LlenarDataSet( false ) )
{
strError = objConexionBd.Error;
objConexionBd.CerrarCnx();
objConexionBd = null;
return false;
}
Generico.DataSource = objConexionBd.DataSet_Lleno.Tables[0];
Generico.DataValueField = strCampoID;
Generico.DataTextField = strCampoTexto;
Generico.DataBind();
objConexionBd.CerrarCnx();
objConexionBd = null;
return true;
}
catch (Exception ex)
{
strError = ex.Message;
return false;
}
}
示例2: FillDataToRadioButtonList
public static void FillDataToRadioButtonList(RadioButtonList control, string table, string dataTextField, string dataValueField)
{
opendata();
string strCommand = "SELECT " + dataTextField + ", " + dataValueField + " FROM " + table;
sqladapter = new SqlDataAdapter(strCommand, sqlconn);
mydata = new DataSet();
sqladapter.Fill(mydata, strCommand);
control.DataSource = mydata;
control.DataTextField = dataTextField;
control.DataValueField = dataValueField;
control.DataBind();
closedata();
}
示例3: createItemAdPos
public static void createItemAdPos(ref RadioButtonList rbl)
{
List<string[]> l = listAds();
rbl.DataSource = from obj in l
select new
{
Id = obj[0],
Name = obj[1]
};
rbl.DataTextField = "Name";
rbl.DataValueField = "Id";
rbl.DataBind();
rbl.SelectedIndex = 0;
}
示例4: createItemLanguage
public static void createItemLanguage(ref RadioButtonList rbl)
{
List<string[]> l = new List<string[]> { new string[] { "1", "Việt Nam" }, new string[] { "2", "English" } };
rbl.DataSource = from obj in l
select new
{
Id = obj[0],
Name = obj[1]
};
rbl.DataTextField = "Name";
rbl.DataValueField = "Id";
rbl.DataBind();
rbl.SelectedIndex = 0;
}
示例5: createItemAdPos
public static void createItemAdPos(ref RadioButtonList rbl)
{
List<string[]> l = new List<string[]>
{
new string[] { "0", "Slideshow" },
new string[] { "1", "Advertising" },
};
rbl.DataSource = from obj in l
select new
{
Id = obj[0],
Name = obj[1]
};
rbl.DataTextField = "Name";
rbl.DataValueField = "Id";
rbl.DataBind();
rbl.SelectedIndex = 0;
}
示例6: SingleSelectControl
public SingleSelectControl(SingleSelect question, RepeatDirection direction)
{
rbl = new RadioButtonList();
rbl.CssClass = "alternatives";
rbl.ID = "q" + question.ID;
rbl.DataTextField = "Title";
rbl.DataValueField = "ID";
rbl.DataSource = question.GetChildren();
rbl.RepeatLayout = RepeatLayout.Flow;
rbl.RepeatDirection = direction;
rbl.DataBind();
l = new Label();
l.CssClass = "label";
l.Text = question.Title;
l.AssociatedControlID = rbl.ID;
Controls.Add(l);
Controls.Add(rbl);
}
示例7: TreeNavigatorControl
public TreeNavigatorControl(HierarchyNavTable hierarchy, List<UserAction> actions)
{
this.hierarchy = hierarchy;
this.actions = actions;
tree = new TreeView();
tree.ShowLines = true;
WC.TreeNode item;
foreach (HierarchyRow r in hierarchy.Rows)
{
if (r.ParentId == null)
{
item = new WC.TreeNode(r.Caption, r.NavId.ToString());
AddSubtreeForItem(r, item);
tree.Nodes.Add(item);
}
}
tree.SelectedNodeChanged += SelectionChanged;
tree.SelectedNodeStyle.Font.Bold = true;
radios = new RadioButtonList();
radios.DataSource = actions;
radios.DataBind();
// if there is only one action option, don`t show the radios at all
if (actions.Count == 1)
{
radios.SelectedIndex = 0;
radios.Visible = false;
}
radios.SelectedIndexChanged += SelectionChanged;
radios.AutoPostBack = true;
this.Controls.Add(tree);
this.Controls.Add(radios);
}
示例8: RenderAtDesignTime
/// <summary>
/// Renders the control in the designer
/// </summary>
public void RenderAtDesignTime()
{
if (this._isDesignTime)
{
this.Controls.Clear();
if (this.SurveyId == -1)
{
Literal child = new Literal();
child.Text = "Please set the SurveyId property first!";
this.Controls.Add(child);
}
else
{
ArrayList list = new ArrayList();
list.Add("#Answer 1#");
list.Add("#Answer 2#");
list.Add("#Answer 3#");
list.Add("#Answer 4#");
list.Add("#Answer 5#");
Table table = new Table();
new TableRow();
new TableCell();
TableRow row = new TableRow();
TableCell cell = new TableCell();
Button button = new Button();
Button button2 = new Button();
PlaceHolder holder = new PlaceHolder();
new Literal();
table.Rows.Add(this.BuildRow("Error Message", this.QuestionValidationMessageStyle));
table.Rows.Add(this.BuildRow("Confirmation message", this.ConfirmationMessageStyle));
row.ControlStyle.CopyFrom(this.QuestionStyle);
cell.Controls.Add(new LiteralControl("1. #Question#"));
Label label = new Label();
label.Text = this.QuestionValidationMark;
label.ControlStyle.CopyFrom(this.QuestionValidationMarkStyle);
cell.Controls.Add(label);
row.Cells.Add(cell);
table.Rows.Add(row);
RadioButtonList list2 = new RadioButtonList();
list2.Width = Unit.Percentage(100.0);
list2.DataSource = list;
list2.ControlStyle.CopyFrom(this.AnswerStyle);
list2.DataBind();
table.Rows.Add(this.BuildRow(list2, this.AnswerStyle));
button.ControlStyle.CopyFrom(this.ButtonStyle);
button.Text = (this.ButtonText == null) ? "Submit" : this.ButtonText;
button2.ControlStyle.CopyFrom(this.ButtonStyle);
button2.Text = (this.NextPageText == null) ? "Next page >>" : this.NextPageText;
holder.Controls.Add(button);
holder.Controls.Add(button2);
holder.Controls.Add(new LiteralControl(string.Format("Page {0} / {1}", 1, 10)));
table.Rows.Add(this.BuildRow(holder, this.FootStyle));
table.CellPadding = this.CellPadding;
table.CellSpacing = this.CellSpacing;
table.Width = base.Width;
table.Height = base.Height;
table.BackColor = base.BackColor;
this.Controls.Add(table);
}
}
}
示例9: AppendEditViewFieldsEdit
//.........这里部分代码省略.........
// 07/28/2010 We are getting an undefined exception on the Accounts List Advanced page.
// Lets drop back to using KeySort.
//lstField = new DropDownList();
}
tdField.Controls.Add(lstField);
lstField.ID = sDATA_FIELD + sIDSuffix;
lstField.TabIndex = nFORMAT_TAB_INDEX;
// 08/01/2010 Apply ACL Field Security.
lstField.Enabled = bIsWriteable;
// 07/23/2010 Lets try the latest version of the ListSearchExtender.
// 07/28/2010 We are getting an undefined exception on the Accounts List Advanced page.
/*
if ( nFORMAT_ROWS == 0 )
{
AjaxControlToolkit.ListSearchExtender extField = new AjaxControlToolkit.ListSearchExtender();
extField.ID = lstField.ID + "_ListSearchExtender";
extField.TargetControlID = lstField.ID;
extField.PromptText = L10n.Term(".LBL_TYPE_TO_SEARCH");
extField.PromptCssClass = "ListSearchExtenderPrompt";
tdField.Controls.Add(extField);
}
*/
try
{
if ( !Sql.IsEmptyString(sDATA_FIELD) )
{
// 12/04/2005 Don't populate list if this is a post back.
if ( !Sql.IsEmptyString(sCACHE_NAME) && (!bIsPostBack) )
{
// 12/24/2007 Use an array to define the custom caches so that list is in the Cache module.
// This should reduce the number of times that we have to edit the SplendidDynamic module.
// 02/16/2012 Move custom cache logic to a method.
SplendidCache.SetListSource(sCACHE_NAME, lstField);
lstField.DataBind();
// 08/08/2006 Allow onchange code to be stored in the database.
// ListBoxes do not have a useful onclick event, so there should be no problem overloading this field.
if ( !Sql.IsEmptyString(sONCLICK_SCRIPT) )
lstField.Attributes.Add("onchange" , sONCLICK_SCRIPT);
// 02/21/2006 Move the NONE item inside the !IsPostBack code.
// 12/02/2007 We don't need a NONE record when using multi-selection.
// 12/03/2007 We do want the NONE record when using multi-selection.
// This will allow searching of fields that are null instead of using the unassigned only checkbox.
if ( !bUI_REQUIRED )
{
lstField.Items.Insert(0, new ListItem(L10n.Term(".LBL_NONE"), ""));
// 12/02/2007 AppendEditViewFields should be called inside Page_Load when not a postback,
// and in InitializeComponent when it is a postback. If done wrong,
// the page will bind after the list is populated, causing the list to populate again.
// This event will cause the NONE entry to be cleared. Add a handler to catch this problem,
// but the real solution is to call AppendEditViewFields at the appropriate times based on the postback event.
lstField.DataBound += new EventHandler(SplendidDynamic.ListControl_DataBound_AllowNull);
}
}
if ( rdr != null )
{
try
{
// 02/21/2006 All the DropDownLists in the Calls and Meetings edit views were not getting set.
// The problem was a Page.DataBind in the SchedulingGrid and in the InviteesView. Both binds needed to be removed.
// 12/30/2007 A customer needed the ability to save and restore the multiple selection.
// 12/30/2007 Require the XML declaration in the data before trying to treat as XML.
string sVALUE = Sql.ToString(rdr[sDATA_FIELD]);
if ( nFORMAT_ROWS > 0 && sVALUE.StartsWith("<?xml") )
{
XmlDocument xml = new XmlDocument();
xml.LoadXml(sVALUE);
示例10: FillRadiobtnList
public void FillRadiobtnList(ref RadioButtonList objrbtnList, string strQuery, string strTextField, string strValueField, string strOrderBy, string strQueryCondition = "")
{
dsCommon = new DataSet();
dsCommon = CrystalConnection.CreateDatasetWithoutTransaction(strQuery + " " + strQueryCondition + " " + strOrderBy);
objrbtnList.DataTextField = strTextField;
objrbtnList.DataValueField = strValueField;
objrbtnList.DataSource = dsCommon.Tables[0].DefaultView;
objrbtnList.DataBind();
}
示例11: fillData
/// <summary>
/// Lägger till varje fråga i paneln och visar om man har svarat rätt eller fel.
/// </summary>
/// <param name="queID"></param>
/// <param name="ttID"></param>
private void fillData(string queID, string ttID)
{
clsFillQuestion quest = new clsFillQuestion();
Tuple<DataTable, string, int, string, string> Que = quest.readXML(queID, ttID);
DataTable dt = Que.Item1;
Label lbN = new Label();
string img = "";
if (Que.Item5 != null)
{
img = "<img src='pictures/" + Que.Item5 + "' style='height: 150px; width: 150px;'alt='bilden' />";
}
lbN.ID = "QUEST_" + queID;
lbN.Text = "<h5>" + Que.Item2 + "</h5> " + img + "<br />";
panData.Controls.Add(lbN);
int many = 0;
for (int i = 0; i < Que.Item1.Rows.Count; i++)
{
if (Que.Item1.Rows[i]["answ"].ToString().ToUpper() == "TRUE")
{
many += 1;
}
}
if (many > 1) //Om det finns flera valmöjligheter så sätter vi ut en checkboxliist
{
CheckBoxList li = new CheckBoxList();
li.ID = queID;
li.DataTextField = "name";
li.DataValueField = "id";
li.DataSource = dt;
li.DataBind();
li.Enabled = false;
for (int i = 0; i < dt.Rows.Count; i++) //KRyssar i de som redan användaren har kryssat i
{
int val = 0;
if (dt.Rows[i]["sel"].ToString().ToUpper() == "TRUE")
{
if (int.TryParse(dt.Rows[i]["id"].ToString(), out val))
{
li.Items.FindByValue(val.ToString()).Selected = true; //Sätter alla som finns till true så att den kan vara multippella
li.Items.FindByValue(val.ToString()).Attributes.Add("style", "border: 2px solid red;");
}
val = 0;
}
if (dt.Rows[i]["answ"].ToString().ToUpper() == "TRUE")
{
if (int.TryParse(dt.Rows[i]["id"].ToString(), out val))
{
li.Items.FindByValue(val.ToString()).Attributes.Add("style", "border: 2px solid green;"); //= System.Drawing.Color.Green; //Sätter alla som finns till true så att den kan vara multippella
}
val = 0;
}
}
panData.Controls.Add(li);
}
else
{
RadioButtonList li = new RadioButtonList();
li.ID = queID;
li.DataTextField = "name";
li.DataValueField = "id";
li.DataSource = Que.Item1;
li.DataBind();
li.Enabled = false;
for (int i = 0; i < dt.Rows.Count; i++)
{
int val = 0;
if (dt.Rows[i]["sel"].ToString().ToUpper() == "TRUE")
{
if (int.TryParse(dt.Rows[i]["id"].ToString(), out val))
{
li.SelectedValue = val.ToString();
li.Items.FindByValue(val.ToString()).Attributes.Add("style", "border: 2px solid red;");
}
}
if (dt.Rows[i]["answ"].ToString().ToUpper() == "TRUE") //Om man vill kolla på frågorna igen så markeras den grön om det är okej
{
if (int.TryParse(dt.Rows[i]["id"].ToString(), out val))
{
li.Items.FindByValue(val.ToString()).Attributes.Add("style", "border: 2px solid green;");
}
}
}
panData.Controls.Add(li);
}
}
示例12: TestUpdate
public void TestUpdate()
{
OrganizationDetailPanel testpage = new OrganizationDetailPanel();
DetailPanelPageProxy proxy = new DetailPanelPageProxy(testpage);
IOrganizationApi organizationApi = SpringContext.Current.GetObject<IOrganizationApi>();
Guid guid = Guid.NewGuid();
string surfix = guid.ToString().Substring(0, 5);
using (var httpEnv = new HttpEnvironment())
{
#region Setup the pre-required data
//Setup the right URL
httpEnv.SetRequestUrl("/OrganizationDetailPanel/DynamicPage.svc?Domain=Department");
OrganizationObject testOrganization = new OrganizationObject()
{
OrganizationCode = "78903"+surfix,
OrganizationName = "testOrganizationUpdate" + surfix,
OrganizationTypeId = organizationApi.FindOrganizationTypes(new List<string>() { "Department" }).Select(x => x.OrganizationTypeId).FirstOrDefault(),
Status = OrganizationStatus.Enabled
};
organizationApi.Save(testOrganization);
createdOrganizationIds.Add(testOrganization.OrganizationId);
#endregion
OrganizationObject organization = organizationApi.GetOrganizationByName("testOrganizationUpdate"+surfix);
#region Setup the Updated Code
//Binding the required web controls
TextBox organizationCode = new TextBox();
organizationCode.Text = "78903" + surfix;
proxy.Set("TextBoxOrganizationCode", organizationCode);
TextBox organizationName = new TextBox();
organizationName.Text = "OrganziationTest" + surfix;
proxy.Set("TextBoxOrganizationName", organizationName);
DropDownList DropDownListOrganizationType = new DropDownList();
var typeData = organizationApi.FindOrganizationTypes(new List<string>() { "Department" }).Select(x => x.OrganizationTypeId);
DropDownListOrganizationType.Items.Clear();
DropDownListOrganizationType.DataSource = typeData;
DropDownListOrganizationType.DataBind();
DropDownListOrganizationType.SelectedIndex = 1;
proxy.Set("DropDownListOrganizationType", DropDownListOrganizationType);
Array statusData = new string[] { "Enabled", "Disabled", "Pending" };
RadioButtonList RadioButtonListOrganizationStatus = new RadioButtonList();
RadioButtonListOrganizationStatus.DataSource = statusData;
RadioButtonListOrganizationStatus.DataBind();
RadioButtonListOrganizationStatus.SelectedIndex = 0;
proxy.Set("RadioButtonListOrganizationStatus", RadioButtonListOrganizationStatus);
#endregion
proxy.Update(organization.OrganizationId.ToString());
OrganizationObject organizationUpdated = organizationApi.GetOrganization(organization.OrganizationId);
Assert.AreNotEqual(organizationUpdated.OrganizationName, "testOrganization" + surfix);
Assert.AreEqual(organizationUpdated.OrganizationName, "OrganziationTest" + surfix);
}
}
示例13: FillToRadioList
public void FillToRadioList(RadioButtonList radiolist, DataTable datatable, string displayMember, string valueMember, string selectedIndex)
{
if (datatable != null)
{
radiolist.DataSource = datatable;
radiolist.DataTextField = displayMember;
radiolist.DataValueField = valueMember;
}
else
{
radiolist.DataSource = null;
}
radiolist.DataBind();
if (selectedIndex != "")
{
try
{
radiolist.SelectedValue = selectedIndex;
}
catch (Exception ex)
{
throw new BusinessException(ex.Message.ToString());
}
}
}
示例14: GenrateForm
//.........这里部分代码省略.........
tcrightSagetd.Controls.Add(imb);
tcrightSagetd.Controls.Add(Cex);
break;
}
bool IsRequred = bool.Parse(dt.Rows[i]["IsRequired"].ToString());
if (IsRequred)
{
RequiredFieldValidator rfv = new RequiredFieldValidator();
rfv.ID = "rfv_" + ProfileID;
rfv.ControlToValidate = BDTextBox.ID;
rfv.ErrorMessage = "*";
rfv.ValidationGroup = "UserProfile";
tcrightSagetd.Controls.Add(rfv);
}
break;
case 2://DropDownList
DropDownList ddl = new DropDownList();
ddl.ID = "BDTextBox_" + ProfileID;
ddl.CssClass = "cssClassDropDown";
//ddl.Width = 200;
ddl.EnableViewState = true;
//Setting Data Source
var LinqProvileValue = db.sp_ProfileValueGetActiveByProfileID(ProfileID, GetPortalID);
ddl.DataSource = LinqProvileValue;
ddl.DataValueField = "ProfileValueID";
ddl.DataTextField = "Name";
ddl.DataBind();
if (ddl.Items.Count > 0)
{
ddl.SelectedIndex = 0;
}
//Adding in Pandel
tcrightSagetd.Controls.Add(ddl);
break;
case 3://CheckBoxList
CheckBoxList chbl = new CheckBoxList();
chbl.ID = "BDTextBox_" + ProfileID;
chbl.CssClass = "cssClassCheckBox";
chbl.RepeatDirection = System.Web.UI.WebControls.RepeatDirection.Horizontal;
chbl.RepeatColumns = 2;
chbl.EnableViewState = true;
//Setting Data Source
LinqProvileValue = db.sp_ProfileValueGetActiveByProfileID(ProfileID, GetPortalID);
chbl.DataSource = LinqProvileValue;
chbl.DataValueField = "ProfileValueID";
chbl.DataTextField = "Name";
chbl.DataBind();
if (chbl.Items.Count > 0)
{
chbl.SelectedIndex = 0;
}
//Adding in Pandel
tcrightSagetd.Controls.Add(chbl);
break;
case 4://RadioButtonList
RadioButtonList rdbl = new RadioButtonList();
示例15: RadioListBind
protected void RadioListBind(RadioButtonList List, string DataTypeValue)
{
DataTable dt = new DataTable();
dt = bllTypeData.GetTypeDataList(DataTypeValue);
List.DataSource = dt;
List.DataTextField = "DataValue";
List.DataValueField = "DataCode";
List.DataBind();
}