473,396 Members | 1,891 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

DataList no Accessible

A strange problem i am facing i bind DataList on link button Argument Event.

<asp:DataList id="DataList2" runat="server" horizontalalign="Left" repeatdirection="Horizontal" repeatcolumns="3" DataKeyField="id" >
<ItemTemplate>
<asp:checkbox id="chkItem" runat="server" value='<%# Eval("extras")%>' /><asp:label id="Label5" runat="server"><%# " " +Eval("extras")%></asp:label>
</itemtemplate>
<itemstyle width="120px" forecolor="#404040" horizontalalign="Left" font-names="Arial" font-size="10pt" />
</asp:DataList>

/////////////////////////////////////

private void LoadUserControl()
{
if (typee == "Other")
{




string query444 = "Select * from extras where mid=" + foodid + " AND psizes=0 AND type=1";
SqlCommand cmd333 = new SqlCommand(query444, conn);

conn.Open();

reader444 = cmd333.ExecuteReader();
if (reader444.HasRows)
{
DataList1.DataSource = reader444;
DataList1.DataBind();

}
else
{
ex1.Visible = false;
ex2.Visible = false;
ex3.Visible = false;
}
reader444.Close();

string query4 = "Select * from extras where mid=" + foodid + " AND psizes=0 AND type=2";
SqlCommand cmd3 = new SqlCommand(query4, conn);
reader4 = cmd3.ExecuteReader();
if (reader4.HasRows)
{
DataList2.DataSource = reader4;
DataList2.DataBind();

}
else
{
exx1.Visible = false;
exx2.Visible = false;
exx3.Visible = false;
}
reader4.Close();
conn.Close();


}
}



protected void Page_Load(object sender, EventArgs e)
{
conn.Close();

rname = Session["rname"].ToString();
restid= Session["restid"].ToString();
menuu= Session["menuu"].ToString();
mdetail= Session["mdetail"].ToString();
int mid1 = int.Parse(Session["mid"].ToString());
menucat.Text = menuu;
Label1.Text = mdetail;
SqlDataAdapter myCommand = new SqlDataAdapter("Select * from other where restid LIKE '%" + restid + "%' AND menucat LIKE '%" + menuu + "' AND mid LIKE '%"+mid1+"%'", conn);

DataSet ds = new DataSet();
myCommand.Fill(ds);

DataList3.DataSource = ds;
DataList3.DataBind();


}
protected void CommandBtn2_Click(object sender, CommandEventArgs e)
{


string[] strPartss = rname.Split('_');


features.Visible = true;
extras.Visible = true;


string str = e.CommandArgument.ToString();

string[] strParts = str.Split('_');

price = strParts[0].ToString();
price = price.Trim();
foodname = strParts[1].ToString();
foodname = foodname.Trim();
foodid = strParts[2].ToString();
foodid = foodid.Trim();
typee = strParts[3].ToString();
typee = typee.Trim();
string fooddesc = strParts[4].ToString();

Label3.Text = foodname;
Label2.Text = fooddesc;

string fsizes = foodname + " (£" + price + ")";
sizes.Items.Add(fsizes);

LoadUserControl();
}



When press submit and use Datalist2.Items.Count it gives 0 while there are items in datalist. Datalist2 is not accessible after bind. While other datalists on same page giving perfect Items count. Here is button code:




protected void Button1_Click(object sender, EventArgs e)
{

menucat.Text += DataList2.Items.Count.ToString() + "<br />";


}


Please help me i have stuck in to strange kind of situation.
May 7 '09 #1
0 1162

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Chumley the Walrus | last post by:
I'm using a subroutine/helper function display an image (the image would be displayed inside a datalist control's <itemtemplate> ) <script language="VB" runat="server"> Public Sub...
10
by: Bharat | last post by:
Hi Folks, Suppose I have two link button on a page (say lnkBtn1 and lnkBtn2). On the click event of the lnkbtn1 I have to add a dynamically created control. And On the click event of the lnkBtn2 I...
2
by: Chris Fink | last post by:
This should be relatively simple but I am unable to find an asp:button tag in a datalist footer. I have tried it numerous ways including the FindControl method from the many events that the...
4
by: Patrick.O.Ige | last post by:
I have a CheckBoxList in a DataList and i'm trying to get item Selected after doing a postBack. I have set my CheckBoxlist AutoPostBack="True" Any ideas what 'm doing wrong? It seems not to...
6
by: Paul | last post by:
I am trying to use a DataList and the ItemTemplate. I am binding the Datalist to a SQL query that gives me a list of Items with a Parent Category. I want to loop through all the items, but...
2
by: Hans Merkl | last post by:
Hi, I am trying to use a user control as EditItemTemplate in a DataList. It loads fine but I can't figure out how to bind to the data of the DataList. Here is what I have got so far: ...
3
by: Mirek Endys | last post by:
I have DataList as part of DataList item. DataList in DataList. The parent DataList working well including Edit command, that shows Edit template and correctly bind the data into edit template...
0
by: Les Caudle | last post by:
I have a menu system composed of a DataList nested inside a DataList. The outer DataList has it's DataSource (composed of a DataSet with two tables linked by a CategoryPagesRelation Relation) set...
3
by: Crazy Cat | last post by:
Hi all, I am developing an asp.net 2.0 application in Visual Studio 2005. On my page I have a simple datalist that is bound programmatically to a collection of simple objects. On this page I...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
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,...
0
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...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
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...
0
agi2029
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,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.