|
Hi,
I am using ASP.NET and C# 2.0. I have the following piece of code in my gridview control:
<asp:TemplateField HeaderText="Action">
<ItemTemplate>
<a href='UpdateOrderItems.aspx?OrderID=<%# DataBinder.Eval(Container.DataItem, "ID") %>'>Insert / Update Items</a>
</ItemTemplate>
<HeaderStyle CssClass="GridViewHeader" />
<ItemStyle CssClass="GridViewCell" />
</asp:TemplateField>
Currently the text of the link is Insert / Update Items. I want to do a test on this, if the order has been placed, then I want the link text to display "View", and if it has not been placed, the display "Insert / Update Items". I have now I idea where to do this test?? In my C# class behind the .aspx file? The reson being because the gridview populates the rows and coloumn for you.
Please can someone advise.
Regards,
ma se
|
|
|
|
|
Hello ma se
There are different ways of doing this. One way is to create a method in the code behind file that returns the value that you want to display. So you replace your "Insert / Update Items" part with a method call as the sample below. You can send any data to this method for it to be able to return the right value. Remember to make the method protected, otherwise you cant use it from the aspx page.
<asp:TemplateField HeaderText="Action">
<ItemTemplate>
<a href='UpdateOrderItems.aspx?OrderID=<%# DataBinder.Eval(Container.DataItem, "ID") %>'><%# GetUrlActionText( DataBinder.Eval(Container.DataItem, "ID") %></a>
</ItemTemplate>
<HeaderStyle CssClass="GridViewHeader" />
<ItemStyle CssClass="GridViewCell" />
</asp:TemplateField>
// Put in code behind file
protected string GetUrlActionText(string id)
{
// Code to return either Insert / Update Items or View
bool isOrdered = GetOrderIsPlaced(id);
if (isOrdered)
return "View";
else
return "Insert / Update Items";
}
Another way is to make the check in the aspx file.
<% if (orderPlaced == true) { %>
<asp:TemplateField HeaderText="Action">
<ItemTemplate>
<a href='UpdateOrderItems.aspx?OrderID=<%# DataBinder.Eval(Container.DataItem, "ID") %>'>View</a>
</ItemTemplate>
<HeaderStyle CssClass="GridViewHeader" />
<ItemStyle CssClass="GridViewCell" />
</asp:TemplateField
<% } else { %>
<asp:TemplateField HeaderText="Action">
<ItemTemplate>
<a href='UpdateOrderItems.aspx?OrderID=<%# DataBinder.Eval(Container.DataItem, "ID") %>'>Insert / Update Items</a>
</ItemTemplate>
<HeaderStyle CssClass="GridViewHeader" />
<ItemStyle CssClass="GridViewCell" />
</asp:TemplateField>
<% } %>
the orderPlaced variable is a protected variable in the code behind class that contains the state of the order.
I hope this helps you out.
Kind Regards,
John Petersen
|
|
|
|
|
Hi guys ..
I m trying to create a setup for my application.i choose the web setup project. I get the following error when i try to add the content files
ERROR: Unable to build project output group 'Content Files from IndusInventory (Active)'
can anybody help...
Thanx
|
|
|
|
|
HI
Guys, i am reading the data from an XML file from website in to my own application in dataset then i have assigned that dataset to the grid as a data source ,when i have used it in separate test sample application in ASP.Net 2.0 on ASP.Net Development server it works fine, but when i use it in my project application in ASP.Net 2.0 on IIS , it throws exception while reading the XML file , "Unable to connect to remote server", plz let me know the solution of this ASAP , thankx in advance.
|
|
|
|
|
when u uploaded your code at server then u should take care of path.
u should use server.mappath() for exact location of file .
Mahendra
|
|
|
|
|
Hi guys,
I’m choosing from a dropdown list,
The "SelectedIndexChanged" handler simply invokes Response.redirect() to another page, and from that page I’m clicking the "Back" IE button,
after going back to the 1st page, the drop down list's selected item is the last one used (the one described above....)
Then, every event that happens (any button clicking or different dropdownlists clicking) will trigger this dropdown list's "SelectedIndexChanged" event, although the dropdown list itself haven't been clicked...
Can't really figure it out..
Thanks,
P.
|
|
|
|
|
well the selected index has changed...
when you press the back button, the page is not refreshed, it's just taken from the local cache; so when you will post it to the server, it will compare the old index with the new index and see that they differ.
|
|
|
|
|
Hi, thanks for the reply,
So how can I avoid this situation, that is, not causing the handler to be invoked
(since i didn't actually changed the DropDown list selection....)
Best,
P.
|
|
|
|
|
Don't use the back button; use a hyperlink;
|
|
|
|
|
Hi
I am getting this error when i am begnining the transaction.(sqltran=sqlconn.BeginTransaction) "Execute requires the command to have a transaction object when the connection assigned to the command is in a pending local transaction. The Transaction property of the command has not been initialized"
But wen i am removing this statement(sqltran=sqlconn.BeginTransaction) the error goes .
Wat cud be the reason???
Thanks
Monika
Monika
|
|
|
|
|
Hi,
giving a litbit of code snippet would be gud idea!
just mark the error line.
and also can you send the whats the error message?
thanks
Nitin...
|
|
|
|
|
hi all,
I have created a template for sending emails to the clients.This template gets values from the database and fills them in.Now I need to retrive the contents of this HTML template in asp.net.
Any ideas on this.
Thanks in advance
Regards
Anuradha
I am using Outlook express to read all the mails in the inbox.How can i know the connecting url of my outlook express.
Thanks in advance.
Regards
Anuradha
|
|
|
|
|
hi,
I am trying to send mail in HTML fomate, the code works well when i send mail to yahoo and gmail. But while sending mail to rediffmail id I am getting Delivary Failed mail, but that Id was correct.When i am trying to send to our own mail server the mail was not delivaring, it was in pending state for more than 24 Hr. But i want to send mail to our own server. What has to be done to make it work??? I had set the msg.Priority = MailPriority.High also.
Plz any one suggest me to rectify this problem
Thanks in advance
Bye
Exelio
Known is drop, unknown is ocean
|
|
|
|
|
Try to send mail using plain text format, to determine if it's the format of the mail that is the problem, or the mail delivery in general.
---
b { font-weight: normal; }
|
|
|
|
|
Hi,
Thankz very much for your suggestion, but still i am getting the same error,
This is the code which I am using,
msg.Subject = "test Mail"
msg.Priority = MailPriority.High
msg.To = sarathy@exelio.com
msg.From = sarathy1234@yahoo.co.in
msg.Body = "This is an test mail with plain test"
SmtpMail.SmtpServer = "localhost"
SmtpMail.Send(msg)
Known is a drop, unknown is ocean
|
|
|
|
|
Then you know that the error has nothing to do with sending html mail.
Is the mail address that you are using as from address registered on the mail server? Most mail servers only allow their own users to send mail through it.
---
b { font-weight: normal; }
|
|
|
|
|
Hi,
I tried this way also as you suggested, but still i am getting the same problem.
plz it's a little bit urgetnt
Bye
Exelio
|
|
|
|
|
Is the mail address that you are using as from address registered on the mail server? Most mail servers only allow their own users to send mail through it.
---
b { font-weight: normal; }
|
|
|
|
|
Hi,
The mail address which i used is sarathy@exelio.com, it's an registered mail id. Past one year i am using it.
Thank you very much sir
bye
Exelio
|
|
|
|
|
But is it the server that handles this email acount that you are trying to use to send mail?
---
b { font-weight: normal; }
|
|
|
|
|
Hi,
Ya the server which i try to connect has that mail id.
Thanks for your replies
Bye
Exelio
|
|
|
|
|
I have a array of file names to be added to a Crystal report. The array size changes. So one option i have is to bind the array to the Formula Feild or to add formula feilds (for that matter any type of fields) to an existing crystal report from the program.
Is there any way to do either of this
AMIF
|
|
|
|
|
ihave the same problem after that i draw the report ..
i work to solve this but i am not optimistic
|
|
|
|
|
hi,
i have 2 dropdownlist inside a datagrid,i want to populate the 2nd dropdownlist based on the value selected from the first dropdownlist
kavitha
|
|
|
|
|
Hi Kavitha,
create two dropdownlist as "ddlParent" and "ddlChild".
Populate the "ddlParent" using
if(!Page.IsPostBack)
{
SqlDataAdapter ad = new SqlDataAdapter("SELECT PersonID FROM Person",myConnection);
DataSet ds = new DataSet();
ad.Fill(ds,"Person");
ddlParent.DataSource = ds;
ddlParent.DataTextField = "PersonID";
ddlParent.DataValueField = "PersonID";
ddlParent.DataBind();
}
Now in the selectedIndexChanged event of the "ddlParent" you will implement the code that will fill the "ddlChild".
private void ddlParent_SelectedIndexChanged(object sender, System.EventArgs e)
{
int personID = Convert.ToInt32(ddlParent.SelectedItem.Value);
string query = "SELECT PhoneNumber,PhoneID FROM Phone WHERE PersonID = "+personID;
SqlDataAdapter ad = new SqlDataAdapter(query,myConnection);
DataSet ds = new DataSet();
ad.Fill(ds,"Phone");
ddlChild.DataSource = ds;
ddlChild.DataTextField = "PhoneNumber";
ddlChild.DataValueField = "PhoneID";
ddlChild.DataBind();
}
Hope this works fine.
with regards
Satips
|
|
|
|