I'm trying to show controls on my webpage when someone clicks a NewUser checkbox but I cant get it working.
Webpage Screenshot
This is my Login.aspx code:
<div class="form-group">
<div class="col-md-offset-2 col-md-10">
<div class="checkbox">
<asp:CheckBox runat="server" ID="NewUser" OnCheckedChanged="UpdateOptions" />
<asp:Label runat="server" AssociatedControlID="NewUser">New User?</asp:Label>
</div>
</div>
</div>
This is my Login.aspx.cs code:
//DM Create event to make controls visible if check box is selected
public void UpdateOptions(object update, EventArgs e)
{
if(NewUser.Checked == true)
{
ConfirmEmailLabel.Visible = true;
TextBox3.Visible = true;
ConfirmPasswordLabel.Visible = true;
TextBox4.Visible = true;
Firstname.Visible = true;
TextBox1.Visible = true;
Lastname.Visible = true;
TextBox2.Visible = true;
}
else
{
ConfirmEmailLabel.Visible = false;
TextBox3.Visible = false;
ConfirmPasswordLabel.Visible = false;
TextBox4.Visible = false;
Firstname.Visible = false;
TextBox1.Visible = false;
Lastname.Visible = false;
TextBox2.Visible = false;
}
}
Any ideas would be much appreciated?
Add this
<asp:CheckBox runat="server" ID="NewUser" OnCheckedChanged="UpdateOptions" AutoPostBack="true"/>
You should set true AutoPostBack property of checkbox.
<asp:CheckBox runat="server" AutoPostBack="True" ID="NewUser" OnCheckedChanged="UpdateOptions" />
Related
protected void Page_Load(object sender, EventArgs e)
{
if (Page.IsPostBack)
{
filldropdown(dllselection.SelectedValue);
Code.Enabled = true;
if(dllselection.SelectedValue=="")
{
Code.Enabled = false;
}
}
}
i think there something wrong with the page load,my 2nd dropdownlist is depend on 1st dropdownlist selection.
<div class="form-group">
<div class="form-group">
<label for="inputEmail3" class="col-sm-2 control-label" style="color:black" >Main Category</label>
<div class="col-sm-3">
<asp:DropDownList ID="dllselection" runat="server" CssClass="form-control" AutoPostBack="true" required>
<asp:ListItem Text="Please Select" Value=""></asp:ListItem>
<asp:ListItem Text="HR" Value="M_1"></asp:ListItem>
<asp:ListItem Text="IT" Value="M_2"></asp:ListItem>
<asp:ListItem Text="Maintenance" Value="M_3"></asp:ListItem>
</asp:DropDownList>
</div>
</div>
<div class="form-group">
<label for="Training" style="color:black" class="col-sm-2 control-label">Sub Category</label>
<div class="col-sm-3">
<asp:DropDownList ID="Code" Enabled="false" onchange="javascript:return dropdown(this);" runat="server" CssClass="form-control" ValidationGroup="G1" required></asp:DropDownList>
</div>
</div>
everytime i submit pass data to database,the value for the 2nd dropdownlist always the 1st value.
public void filldropdown(string item)
{
int loggedUserID = Convert.ToInt32(Session["loggedUserID"]);
List<BOL.UserInfo> userslist = new UserInfos().List();
BOL.UserInfo loggeduser = userslist.Where(x => x.UserID == loggedUserID).FirstOrDefault();
// int ID = 10;
List<e_request> role = new e_requests().dropdownlistG(loggeduser.SUBSIDIARY_CD, item);
Code.DataSource = role;
Code.DataTextField = "CAT_DESC";
Code.DataValueField = "SUB_CAT";
Code.DataBind();
}
You can filling drop down on postback which you should not if you want to keep selection. use !Page.IsPostBack instead of Page.IsPostBack
Change
if (Page.IsPostBack)
{
To
if (!Page.IsPostBack)
{
On more thing you may need to put condition out side !Page.IsPostBack as you would need it to be executed on postback
if (!Page.IsPostBack)
{
filldropdown(dllselection.SelectedValue);
}
Code.Enabled = true;
if(dllselection.SelectedValue=="")
{
Code.Enabled = false;
}
Also note you may need to fill the second dropdown on SelectedIndexChange of dllselection and need to set AutoPostBack of dllselection true.
Try this:
if (!IsPostBack)
{
if (dllselection.SelectedValue == "")
{
Code.Enabled = false;
}
else
{
Code.Enabled = true;
filldropdown(dllselection.SelectedValue);
}
}
Try to Load Method in
if (!Page.IsPostBack)
{
filldropdown(dllselection.SelectedValue);
Code.Enabled = true;
if(dllselection.SelectedValue=="")
{
Code.Enabled = false;
}
}
Update:
you need to fill the second dropdown on SelectedIndexChange of dllselection and need to set AutoPostBack = true of dllselection .
<asp:DropDownList ID="logList" runat="server" AutoPostBack="True"
onselectedindexchanged="itemSelected">
</asp:DropDownList>
protected void Page_Load(object sender, EventArgs e)
{
if(!Page.IsPostBack){
filldropdown(dllselection.SelectedValue);
Code.Enabled = true;
if(dllselection.SelectedValue=="")
{
Code.Enabled = false;
}
}
}
add OnSelectedIndexChanged="dllselection_SelectedIndexChanged" to my 1st dropdownlist.
protected void dllselection_SelectedIndexChanged(object sender, EventArgs e)
{
if (dllselection.SelectedIndex == 0)
{
Code.Enabled = false;
}
else
{
Code.Enabled = true;
//fill Code
filldropdown(dllselection.SelectedValue);
}
}
I am trying to create a simple form generating webpage that user can select different controls via a DropDownList, add a Text property to it(and a GroupName property if ii was a RadioButton) and then click a button to generate that control right in the page for previewing purpose (I am also going to add another button to insert the form's information in a database but this is not my problem right now)
this is my aspx page:
<div class="main-wrapper">
<form dir="rtl" id="form" runat="server">
<label>Desired Control : </label>
<asp:DropDownList AutoPostBack="true" ID="ddlControlType" OnSelectedIndexChanged="ddlControlType_SelectedIndexChanged" runat="server">
<asp:ListItem Text="label"></asp:ListItem>
<asp:ListItem Text="text box"></asp:ListItem>
<asp:ListItem Text="check box"></asp:ListItem>
<asp:ListItem Text="radio button"></asp:ListItem>
</asp:DropDownList>
<br /><br />
<label class="label">control's text : </label>
<asp:TextBox ID="txtboxText" runat="server" CssClass="txtbox"></asp:TextBox>
<label class="label">group name (only for radio button)</label>
<asp:TextBox Enabled="false" ID="txtboxGroupName" runat="server" CssClass="txtbox"></asp:TextBox>
<br /><br />
<asp:Button ID="btnAddControl" CssClass="btn" Text="add to form" OnClick="btnAddControl_Click" runat="server" />
<hr />
<h1>form preview</h1>
<asp:Panel ID="panel" runat="server">
</asp:Panel>
</form>
this is the code behind:
public Dictionary<string, Type> ControlTypes
{
get { return (Dictionary<string, Type>)Session["ControlTypes"]; }
set { Session["ControlTypes"] = value; }
}
public int NumberOfControls
{
get { return (int)ViewState["NumOfControls"]; }
set { ViewState["NumOfControls"] = value; }
}
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
this.NumberOfControls = 0;
ControlTypes = new Dictionary<string, Type>();
}
else
this.CreateControls();
}
private void CreateControls()
{
for (int counter = 0; counter < this.NumberOfControls; counter++)
{
string controlId = "control_id_" + counter.ToString();
Type controlType = ControlTypes[controlId];
PropertyInfo[] properties = controlType.GetProperties();
object controlObject = Activator.CreateInstance(controlType);
foreach (var property in properties)
{
if (property.Name == "ID")
property.SetValue(controlObject, controlId, null);
}
panel.Controls.Add(controlObject as Control);
}
}
protected void ddlControlType_SelectedIndexChanged(object sender, EventArgs e)
{
switch (ddlControlType.SelectedIndex)
{
case 0:
case 2:
txtboxText.Enabled = true;
txtboxGroupName.Enabled = false;
break;
case 1:
txtboxText.Enabled = false;
txtboxGroupName.Enabled = false;
break;
case 3:
txtboxText.Enabled = true;
txtboxGroupName.Enabled = true;
break;
}
}
protected void btnAddControl_Click(object sender, EventArgs e)
{
Control tempControl = null;
switch (ddlControlType.SelectedIndex)
{
case 0:
tempControl = new Label();
((Label)tempControl).Text = txtboxText.Text;
break;
case 1:
tempControl = new TextBox();
break;
case 2:
tempControl = new CheckBox();
((CheckBox)tempControl).Text = txtboxText.Text;
break;
case 3:
tempControl = new RadioButton();
((RadioButton)tempControl).Text = txtboxText.Text;
((RadioButton)tempControl).GroupName = txtboxGroupName.Text;
break;
}
string controlId = "control_id_" + this.NumberOfControls.ToString();
tempControl.ID = controlId;
panel.Controls.Add(tempControl);
this.NumberOfControls++;
ControlTypes.Add(controlId, tempControl.GetType());
}
as you can see, I preserve the id's of the controls, but the viewstate won't update their values.the controls will be added to the form with the desired id, but its values won't be set at all
what should I do?
I have the following form in my ASP.net page:
<asp:UpdatePanel runat="server" ClientIDMode="Static" ID="upReg" UpdateMode="Conditional">
<ContentTemplate>
<div class="dvHolder hidOverflow clearfix">
<input id="txtFirst" type="text" name="login" value="" placeholder="First Name" runat="server" />
<asp:Label Text="" runat="server" ID="lblRFName" CssClass="lblStyle" />
</div>
<div class="dvHolder hidOverflow clearfix">
<input id="txtLast" type="text" name="login" value="" placeholder="Last Name" runat="server" />
<asp:Label Text="" runat="server" ID="lblRLName" CssClass="lblStyle" />
</div>
<div class="dvHolder hidOverflow clearfix">
<input id="txtEmail" type="text" name="login" value="" placeholder="Email Address" runat="server" />
<asp:Label Text="" runat="server" ID="lblREmail" CssClass="lblStyle" />
</div>
<div class="dvHolder hidOverflow clearfix">
<input id="txtUser" type="text" name="login" value="" placeholder="Username" runat="server" />
<asp:Label Text="" runat="server" ID="lblRUser" CssClass="lblStyle" />
</div>
<div class="dvHolder hidOverflow clearfix">
<input id="txtPass" type="password" name="login" value="" placeholder="Password" runat="server" />
<asp:Label Text="" runat="server" ID="lblRPass" CssClass="lblStyle" />
</div>
<div class="dvHolder hidOverflow clearfix">
<input id="txtPassC" type="password" name="login" value="" placeholder="Confirm Password" runat="server" />
<asp:Label Text="" runat="server" ID="lblRPassC" CssClass="lblStyle" />
</div>
<div class="dvHolder hidOverflow clearfix setTextRight">
<asp:Button ID="btnRegister" ClientIDMode="Static" runat="server" Text="Register" OnClick="btnRegister_Click" />
<asp:Label runat="server" Text="" ID="lblSuccess" ClientIDMode="Static" />
</div>
</ContentTemplate>
</asp:UpdatePanel>
</div>
Code-behind:
public void btnRegister_Click(object sender, EventArgs e)
{
if (txtFirst.Value == "")
{
lblRFName.Text = "Please enter your first name";
blnFrmComplete = false;
}
else
{
lblRFName.Text = "";
blnFrmComplete = true;
}
if (txtLast.Value == "")
{
lblRLName.Text = "Please enter your last name";
blnFrmComplete = false;
}
else
{
lblRLName.Text = "";
blnFrmComplete = true;
}
if (txtEmail.Value == "")
{
lblREmail.Text = "Please enter your email address";
blnFrmComplete = false;
}
else
{
if (!(IsValidEmail(txtEmail.Value)))
{
lblREmail.Text = "Please enter a valid email address";
blnFrmComplete = false;
}
else
{
if (UserExistsWithEmail()) //function to check if email account already exists
{
lblREmail.Text = "The email already has an account";
blnFrmComplete = false;
}
else
{
lblREmail.Text = "";
blnFrmComplete = true;
}
}
}
if (txtUser.Value == "")
{
lblRUser.Text = "Please enter a desired username";
blnFrmComplete = false;
}
else
{
if (UserExistsWithUsername()) //function to check if username already exists
{
}
else
{
lblRUser.Text = "";
blnFrmComplete = true;
}
}
if (txtPass.Value == "")
{
lblRPass.Text = "Please enter a password";
blnFrmComplete = false;
}
else
{
if (txtPassC.Value != "" && txtPass.Value == txtPassC.Value)
{
lblRPass.Text = "";
blnFrmComplete = true;
}
else
{
lblRPass.Text = "Password do not match";
blnFrmComplete = false;
}
}
if (txtPassC.Value == "")
{
if (txtPass.Value != "")
{
lblRPassC.Text = "Please confirm your password";
blnFrmComplete = false;
}
else
{
lblRPassC.Text = "Please enter your confirmed password";
blnFrmComplete = false;
}
}
else
{
if (txtPass.Value != "" || txtPass.Value == txtPassC.Value)
{
lblRPassC.Text = "";
blnFrmComplete = true;
}
else
{
lblRPassC.Text = "Confirm password do not match";
blnFrmComplete = false;
}
}
if (blnFrmComplete == true)
{
CreateNewUser();
}
upReg.Update();
}
The issue I am having is because it is going sequential, if I am missing the email address but the password is correct it will return true.
How can I modify the code, so if any of the field is either missing or not properly filled in, blnFrmComplete will be false and the rest of the code won't be checked.
Instead of setting your blnFrmComplete to true in every else, just leave it as true, and let them change it to false only if something is not valid. Nothing should ever be setting it back to true.
So start your boolean as true, and only ever switch it to false if something is invalid. If nothing is invalid, then your boolean will still be true.
You should look in to:
<asp:RequiredFieldValidator id="RequiredFieldValidator2"
ControlToValidate="TextBox1"
Display="Static"
InitialValue=""
ErrorMessage="*"
runat="server"/>
https://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.requiredfieldvalidator(v=vs.110).aspx
You should use a method that validates instead of the button-click handler. Return immediately if you detect that it's invalid:
bool IsFormValid()
{
bool valid = !string.IsNullOrWhiteSpace(txtFirst.Value);
if(!valid)
{
lblRFName.Text = "Please enter your first name";
return false;
}
valid = !string.IsNullOrWhiteSpace(txtLast.Value);
if(!valid)
{
lblRLName.Text = "Please enter your last name";
return false;
}
// ...
valid = !string.IsNullOrWhiteSpace(txtEmail.Value);
if (!valid)
{
lblREmail.Text = "Please enter your email address";
return false;
}
// ...
return true;
}
public void btnRegister_Click(object sender, EventArgs e)
{
if (IsFormValid())
{
CreateNewUser();
upReg.Update();
}
}
But if it's ASP.NET you should use the available validators like RequiredFieldValidator.
I have a problem by setting my Buttons visible.
I created some buttons in a MasterPage and set their visibility false.
(button.Visible = false;)
After pressing a button I am redirected to another page.
On this Page (a child from MasterPage) I want to set some buttons visible (Master.FindControl("button").Visible=true), but this is my problem. It doesn´t show up.
MasterPage.master:
<asp:Button ID="b_home" runat="server" Text="Home" CssClass="button" OnClick="b_home_Click"/>
<asp:Button ID="b_profil" runat="server" Text="Profil" CssClass="button" OnClick="b_profil_Click"/>
<asp:Button ID="b_reservieren" runat="server" Text="Reservieren" CssClass="button" OnClick="b_reservieren_Click"/>
<asp:Button ID="b_verleihhistorie" runat="server" Text="Verleihhistorie" CssClass="button" OnClick="b_verleihhistorie_Click"/>
<asp:Button ID="b_warenausgang" runat="server" Text="Warenausgang" CssClass="button" OnClick="b_warenausgang_Click"/>
<asp:Button ID="b_wareneingang" runat="server" Text="Wareneingang" CssClass="button" OnClick="b_wareneingang_Click"/>
<asp:Button ID="b_neueKunden" runat="server" Text="Neue Kunden" CssClass="button" OnClick="b_neueKunden_Click"/>
<asp:Button ID="b_kontakte" runat="server" Text="Kontakte" CssClass="button" OnClick="b_kontakte_Click"/>
</div>
Master.master.cs
protected void Page_Load(object sender, EventArgs e)
{
b_home.Visible = true;
b_kontakte.Visible = true;
b_profil.Visible = false;
b_reservieren.Visible = false;
b_verleihhistorie.Visible = false;
b_warenausgang.Visible = false;
b_wareneingang.Visible = false;
b_neueKunden.Visible = false;
}
Default.aspx.cs
protected void Page_Load(object sender, EventArgs e)
{
if(MasterPage.istAngemeldet)
{
// .p = db.Persons.Where(s => s.Email==benutzername && s.Passwort== passwort).FirstOrDefault();
l_willkommen.Text= "Herzlich Willkommen bei Bee-Coop.at, " + MasterPage.p.Vorname + "!";
LinkButton l1 = (LinkButton)Master.FindControl("LinkButton1");
l1.Text = "[Abmelden]";
#region SideMenu_Control
switch(MasterPage.hatRolle)
{
case 0: Master.FindControl("b_home").Visible = true;
Master.FindControl("b_kontakte").Visible = true;
Master.FindControl("b_profil").Visible = true;
Master.FindControl("b_reservieren").Visible = true;
Master.FindControl("b_verleihhistorie").Visible = true;
Master.FindControl("b_warenausgang").Visible = true;
Master.FindControl("b_wareneingang").Visible = true;
Master.FindControl("b_neueKunden").Visible = true;
break;
case 1: Master.FindControl("b_home").Visible = true;
Master.FindControl("b_kontakte").Visible = true;
Master.FindControl("b_profil").Visible = true;
Master.FindControl("b_reservieren").Visible = true;
Master.FindControl("b_verleihhistorie").Visible = true;
Master.FindControl("b_warenausgang").Visible = true;
Master.FindControl("b_wareneingang").Visible = true;
break;
case 2: Master.FindControl("b_home").Visible = true;
Master.FindControl("b_kontakte").Visible = true;
Master.FindControl("b_profil").Visible = true;
Master.FindControl("b_reservieren").Visible = true;
Master.FindControl("b_verleihhistorie").Visible = true;
break;
case 3: Master.FindControl("b_home").Visible = true;
Master.FindControl("b_kontakte").Visible = true;
break;
}
#endregion
}
}
you start the page_load event everytime the page gets shown, so you set the control's visibility to false you need to change ur code to:
protected void Page_Load(object sender, EventArgs e)
{
switch(MasterPage.hatRolle)
{
case 0: b_home.Visible = true;
b_kontakte.Visible = true;
b_profil.Visible = true;
b_reservieren.Visible = true;
b_verleihhistorie.Visible = true;
b_warenausgang.Visible = true;
b_wareneingang.Visible = true;
b_neueKunden.Visible = true;
break;
//case 1: .....
//...........
}
}
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
b_home.Visible = true;
b_kontakte.Visible = true;
b_profil.Visible = false;
b_reservieren.Visible = false;
b_verleihhistorie.Visible = false;
b_warenausgang.Visible = false;
b_wareneingang.Visible = false;
b_neueKunden.Visible = false;
}
}
I am a new ASP.NET developer and I am struggling right now with the following issue; I have a panel control that has more than one GridView. Only one GridView will be displayed based on the selection from the DropDownList.
Let us assume that we have three GridViews and we have a DropDownList with three options; A, B and C. If I select A, the first GridView will be displayed. After that, if I select B, the second GridView will be displayed in addition to the first displayed GridView. What I want is after selecting any option from the dropdownlist, the GridView and Label control should be removed and replaced with the new result.
So how can I do that?
My ASP.NET code:
<asp:Panel ID="Panel1" runat="server">
<asp:DropDownList ID="DropDownList1" runat="server" AutoPostBack="True" OnSelectedIndexChanged="DropDownList1_SelectedIndexChanged">
<asp:ListItem>Please Select</asp:ListItem>
<asp:ListItem>A</asp:ListItem>
<asp:ListItem>B</asp:ListItem>
<asp:ListItem>C</asp:ListItem>
</asp:DropDownList>
<br /><br />
<asp:GridView ID="GridView1" runat="server" Visible="true"></asp:GridView>
<br />
<asp:GridView ID="GridView2" runat="server" Visible="true"></asp:GridView>
<br />
<asp:GridView ID="GridView3" runat="server" Visible="true"></asp:GridView>
<br /><br />
<asp:Label ID="lblMessage" runat="server" Text=""></asp:Label>
</asp:Panel>
C# Code:
protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
{
if (DropDownList1.SelectedIndex != null)
{
int option = DropDownList1.SelectedIndex;
var myList2 = new List<string>();
myList2.Add("Test");
myList2.Add("Test");
var myList3 = new List<string>();
switch (option)
{
case 1:
if (myList2.Count > 0)
{
GridView1.DataSource = myList2;
GridView1.DataBind();
GridView1.Visible = true;
}
else
{
lblMessage.BackColor = System.Drawing.Color.Yellow;
lblMessage.ForeColor = System.Drawing.Color.Red;
lblMessage.Text = "No Data!";
}
break;
case 2:
if (myList3.Count > 0)
{
GridView1.Visible = false;
GridView2.DataSource = myList3;
GridView2.DataBind();
GridView2.Visible = true;
}
else
{
lblMessage.BackColor = System.Drawing.Color.Yellow;
lblMessage.ForeColor = System.Drawing.Color.Red;
lblMessage.Text = "No Data!";
}
break;
case 3:
if (myList2.Count > 0)
{
GridView1.Visible = false;
GridView2.Visible = false;
GridView3.DataSource = myList2;
GridView3.DataBind();
GridView3.Visible = true;
}
else
{
lblMessage.BackColor = System.Drawing.Color.Yellow;
lblMessage.ForeColor = System.Drawing.Color.Red;
lblMessage.Text = "No Data!";
}
break;
default:
break;
}
}
}
NOTE: As you see in my C# above that in each case in the switch statement, I am removing the controls of the preceding case but this is not the right way, because I need to remove whether GridView or Label controls after selecting any item from the dropdownlist. So is there any way of taking care of this.
Use MultiView control as described here:
Change page like this:
<asp:Panel ID="Panel1" runat="server">
<asp:DropDownList ID="DropDownList1" runat="server" AutoPostBack="True" OnSelectedIndexChanged="DropDownList1_SelectedIndexChanged">
<asp:ListItem>Please Select</asp:ListItem>
<asp:ListItem>A</asp:ListItem>
<asp:ListItem>B</asp:ListItem>
<asp:ListItem>C</asp:ListItem>
</asp:DropDownList>
<br /><br />
<asp:MultiView ID="MainMultiview" runat="server">
<asp:View ID="View1" runat="server">
GridView 1
<asp:GridView ID="GridView1" runat="server" Visible="true"></asp:GridView>
<br />
</asp:View>
<asp:View ID="View2" runat="server">
GridView 2
<asp:GridView ID="GridView2" runat="server" Visible="true"></asp:GridView>
<br />
</asp:View>
<asp:View ID="View3" runat="server">
GridView 3
<asp:GridView ID="GridView3" runat="server" Visible="true"></asp:GridView>
<br />
</asp:View>
</asp:MultiView>
<br />
<asp:Label ID="lblMessage" runat="server" Text=""></asp:Label>
</asp:Panel>
and change code behind in C# class to like this:
protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
{
if (DropDownList1.SelectedIndex != null)
{
int option = DropDownList1.SelectedIndex;
var myList2 = new List<string>();
myList2.Add("Test");
myList2.Add("Test");
var myList3 = new List<string>();
switch (option)
{
case 1:
if (myList2.Count > 0)
{
//GridView1.DataSource = myList2;
//GridView1.DataBind();
//GridView1.Visible = true;
MainMultiview.SetActiveView(View1);
}
else
{
lblMessage.BackColor = System.Drawing.Color.Yellow;
lblMessage.ForeColor = System.Drawing.Color.Red;
lblMessage.Text = "No Data!";
}
break;
case 2:
if (myList2.Count > 0)
{
//GridView1.Visible = false;
//GridView2.DataSource = myList3;
//GridView2.DataBind();
//GridView2.Visible = true;
MainMultiview.SetActiveView(View2);
}
else
{
lblMessage.BackColor = System.Drawing.Color.Yellow;
lblMessage.ForeColor = System.Drawing.Color.Red;
lblMessage.Text = "No Data!";
}
break;
case 3:
if (myList2.Count > 0)
{
//GridView1.Visible = false;
//GridView2.Visible = false;
//GridView3.DataSource = myList2;
//GridView3.DataBind();
//GridView3.Visible = true;
MainMultiview.SetActiveView(View3);
}
else
{
lblMessage.BackColor = System.Drawing.Color.Yellow;
lblMessage.ForeColor = System.Drawing.Color.Red;
lblMessage.Text = "No Data!";
}
break;
default:
break;
}
}
}
Notice gridview can not bind to list of string. But multiview works greate.