|
OK, I can see that you're not working for money, you're just writing code to teach yourself. You should at least look at putting your connection strings into the web config, although this code would still be a long way short of a commercial standard, even if you did that.
I don't see the BindData method, I assume that's the method you want to fill the drop list when the user is editing data ? You have code to fill the drop lists, why do you have a drop list if the item is not being edited ? And why do you read your data source every time, including for rows that are not item rows ?
As I said, a lot of work here. I think you may want to buy a book and work through it, and abandon this test project for now.
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
madhukk wrote: please help me out quickly
It's always amusing to me when people are rude enough to put a time limit on free help, don't post all the code needed to help them, and don't respond when people try to help.
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
im new to asp... i wasted lot of time working on this please help about dropdownlist
|
|
|
|
|
I did help. I responded, and asked for more details, and made some comments. I assume you're doing some sort of self teaching project ? Why not just simplify it for now ?
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
this is complete code what i did.
i am able to access drop list with list items from another table..(dptmnt).
i need to select a list item for each row and should be updated with other columns when i click update link.....
<pre>
SqlConnection cnn = new SqlConnection("Data Source=NETZOOM\\MADHUK_2005;Integrated Security=SSPI;Initial Catalog=master");
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
BindData();
}
private void BindData()
{
SqlCommand cmd = new SqlCommand("employee", cnn);
cmd.Parameters.Add(new SqlParameter("@Employee_Name", SqlDbType.VarChar, 20));
cmd.Parameters["@Employee_Name"].Value = "Employee_Name";
cmd.Parameters.Add(new SqlParameter("@position", SqlDbType.VarChar, 20));
cmd.Parameters["@position"].Value = "position";
cmd.Parameters.Add(new SqlParameter("@Team_Name", SqlDbType.VarChar, 20));
cmd.Parameters["@Team_Name"].Value = "Team_Name";
cmd.Parameters.Add(new SqlParameter("@Employee_Id", SqlDbType.VarChar, 20));
cmd.Parameters["@Employee_Id"].Value = 1;
cmd.CommandType = CommandType.StoredProcedure;
SqlDataAdapter ad1 = new SqlDataAdapter(cmd);
string sql = "select dept from dptmnt";
DataSet ds = new DataSet(sql);
ad1.Fill(ds, "employe");
cnn.Open();
cmd.ExecuteNonQuery();
cnn.Close();
DataGid1.DataSource = ds;
DataGid1.DataBind();
}
protected void DataGid1_EditCommand(object source, DataGridCommandEventArgs e)
{
DataGid1.EditItemIndex = e.Item.ItemIndex;
BindData();
}
}
protected void DataGid1_CancelCommand(object source, DataGridCommandEventArgs e)
{
DataGid1.EditItemIndex = -1;
BindData();
}
protected void DataGid1_UpdateCommand(object source, System.Web.UI.WebControls.DataGridCommandEventArgs e)
{
System.Web.UI.WebControls.TextBox Employee_Name = new System.Web.UI.WebControls.TextBox();
Employee_Name = (System.Web.UI.WebControls.TextBox)e.Item.Cells[1].Controls[1];
System.Web.UI.WebControls.TextBox position = new System.Web.UI.WebControls.TextBox();
position = (System.Web.UI.WebControls.TextBox)e.Item.Cells[2].Controls[1];
System.Web.UI.WebControls.TextBox Team_Name = new System.Web.UI.WebControls.TextBox();
Team_Name = (System.Web.UI.WebControls.TextBox)e.Item.Cells[3].Controls[1];
System.Web.UI.WebControls.TextBox Employee_Id = new System.Web.UI.WebControls.TextBox();
Employee_Id = (System.Web.UI.WebControls.TextBox)e.Item.Cells[4].Controls[1];
SqlCommand cmd = new SqlCommand();
cmd.Connection = cnn;
cmd.CommandText = "update employe set Employee_Name=@Employee_Name,position=@position,Team_Name=@Team_Name where Employee_Id=@Employee_Id";
cmd.Parameters.Add(new SqlParameter("@Employee_Name", SqlDbType.VarChar, 20));
cmd.Parameters["@Employee_Name"].Value = Employee_Name.Text;
cmd.Parameters.Add(new SqlParameter("@position", SqlDbType.VarChar, 20));
cmd.Parameters["@position"].Value = position.Text;
cmd.Parameters.Add(new SqlParameter("@Team_Name", SqlDbType.VarChar, 20));
cmd.Parameters["@Team_Name"].Value = Team_Name.Text;
cmd.Parameters.Add(new SqlParameter("@Employee_Id", SqlDbType.VarChar, 20));
cmd.Parameters["@Employee_Id"].Value = Employee_Id.Text;
cnn.Open();
cmd.ExecuteNonQuery();
cnn.Close();
DataGid1.EditItemIndex = -1;
BindData();
}
protected void DataGid1_SelectedIndexChanged(object sender, EventArgs e)
{
DataGid1.SelectedIndex = -1;
BindData();
}
protected void DataGid1_DeleteCommand(object source, DataGridCommandEventArgs e)
{
SqlCommand cmd = new SqlCommand();
cmd.Connection = cnn;
cmd.CommandText = "Delete employe where Employee_Id='@Employee_Id'";
cnn.Open();
cmd.ExecuteNonQuery();
DataGid1.EditItemIndex = -1;
BindData();
}
protected void DataGid1_ItemDataBound(object sender, System.Web.UI.WebControls.DataGridItemEventArgs e)
{
string sql = "select dept from dptmnt";
DataSet ds = new DataSet();
SqlCommand cmd = new SqlCommand(sql, cnn);
cmd.Connection.Open();
SqlDataReader dr = cmd.ExecuteReader();
if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
{
DropDownList DropDownList1 = (DropDownList)((DataGridItem)e.Item).FindControl("DropDownList1");
ListItem li = new ListItem();
DropDownList1.Items.Add(li);
DropDownList1.DataSource = dr;
DropDownList1.DataValueField = "dept";
DropDownList1.DataTextField = "dept";
DropDownList1.DataBind();
cmd.Connection.Close();
}
}
</pre>
|
|
|
|
|
madhukk wrote: DataGid1.EditItemIndex = e.Item.ItemIndex;
BindData();
But, this just binds the grid to the same data source it had to start with. How is that supposed to help fill any drop down list ?
madhukk wrote: protected void DataGid1_ItemDataBound(object sender, System.Web.UI.WebControls.DataGridItemEventArgs e)
{
string sql = "select dept from dptmnt";
DataSet ds = new DataSet();
SqlCommand cmd = new SqlCommand(sql, cnn);
cmd.Connection.Open();
SqlDataReader dr = cmd.ExecuteReader();
if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
{
DropDownList DropDownList1 = (DropDownList)((DataGridItem)e.Item).FindControl("DropDownList1");
ListItem li = new ListItem();
DropDownList1.Items.Add(li);
DropDownList1.DataSource = dr;
DropDownList1.DataValueField = "dept";
DropDownList1.DataTextField = "dept";
DropDownList1.DataBind();
cmd.Connection.Close();
}
I have the same questions about this mess as I did in my first post.
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
|
you know, every day, people who are obviously not qualified to write commercial code, post here about obviously commercial projects, and we're expect to offer our help for free on projects we can't get, because you've underbid us, obviously on the basis that you don't have the skills to work in this area, and therefore are happy to earn whatever you can get. Then when we answer you, we have to ask questions to try to get to the bottom of things, your code is so bad that we end up commenting on a lot of different things that need improvement, and when we get to the point where we've asked for more info so we can still try to offer you free help, although you're stealing from us, you cut the conversation short by saying something like 'ok thanks I got it....'. Do you really get that you're not able to write software for a client at this point ? Do you have any plans to learn ? Do you understand anything I said ?
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
As i said previously i am very much new to this....
and what i got is im just adding the dropdownlist and i dint write any code to update....
Yes as u said i need to work hard...
|
|
|
|
|
Well, if you're doing paid work, then you need to stop. If you're doing work to learn, then yes, there's nothing wrong with that, but what you're trying to do right now is obviously far too complex for you.
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
Hi,
anybody know that ,
How to get Mac Address ?
Thanx in Advance.
|
|
|
|
|
Priyagdpl wrote: How to get Mac Address ?
Is it related to ASP.Net? NO.
Btw, here [^]is an example of how to do this in C#
Manas Bhardwaj
Please remember to rate helpful or unhelpful answers, it lets us and people reading the forums know if our answers are any good.
|
|
|
|
|
It is not possible.
You can only access the things that comes from Request headers. You can only check IP address of the client. MAC address is not accessible.
|
|
|
|
|
I m building a aspx (c#) web application.
It requires support to french language....
So that the user can just click the option and the messages, Label text, button text font changes from english to french.
Any Article, link url, sample project in C# ASP.net......
Please give suggestion regarding this....
Thanx in advance.....
|
|
|
|
|
You have to make every string in your program read from string tables, and set up string tables for different languages.
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
hi,
can anybody tell why i am getting this message for a partticular web page-'The breakpoint will not currently be hit. No symbols have been loaded for this document' ????But the break points are working fine in other pages
|
|
|
|
|
|
hi navaneeth,i was also readin the same..but how to find your project's dll????????like i am able to see the modules,but i dnt know how to find out which is your projects dll
|
|
|
|
|
Do you have a bin directory ? What version of .NET are you using ? Does the message say that, even if you load the page in question ? Is the breakpoint in an actual page ?
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|
|
|
Also check whether Terminal Service is Running.
Debugging requires Terminal Service. Check whether it is running or not.
|
|
|
|
|
In my page, while page load short description of some articles displayed. when i click the viewmore link the large description of the corresponding article is enabled. This div also has another one linkbutton for view comments. If first i click viewmore link means the large description is displayed.Next i click the viewcomments link means again the short description is displayed. I try to use updatepanel for this. but no solution.
|
|
|
|
|
You probably need to rephrase your question and explain what you are asking clearly.
|
|
|
|
|
what i have understood your question..
you are trying to hide and show div..to do this you will have to use javascript function to hide and show div and
you will load both short and detaild description.. on page load or according to your logic.
Government Dyal Singh College Lahore.
|
|
|
|
|
I dont Think We Need To use javascript give an id to div run at ="server">
and u Can use it in events using the id
Am i Wrong?
If It Helps Click It as Answer
|
|
|
|