|
use the replace method to add another single quote to the parameter
so instead of passing Friend's, you would pass Friend''s
|
|
|
|
|
No - if you're trying to write an apostrophe to a JavaScript function you need to escape it with an \
eg: friend's becomes friend\'s
|
|
|
|
|
Now it works when i Replace the single quotes
like
onclick="fnDelete('<%#DataBinder.Eval(Container,"DataItem.CatId")%>','<%#DataBinder.Eval(Container,"DataItem.Name").ToString().Replace("'", "\\'")%>')"
|
|
|
|
|
To correctly encode a string to put in a Javascript string literal, you have to escape both backslashes and apostrophes.
.Replace("\\", "\\\\").Replace("'", "\\'")
Of course, if you are absolutely sure that the string can never ever contain a backslash, you only need to escape the apostrophes.
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
i have a list that I bind it to gridview.in this list I store id of products.my list is in a session..in itemtemplate column of this gridview I put a button , named delete , for deleting every row.i dont bind this gridview to sqldatasource .it binds to a list.the id of product is one of the columns of gridview.I want to when user click this button the id of that product remove from the list .how should I remove thi sid from my list and where should I write code.please help me.here is gridviewsource:
<asp:gridview id="GridView1" runat="server" autogeneratecolumns="False" height="140px" width="572px" showfooter="True" xmlns:asp="#unknown">
<columns>
<asp:boundfield datafield="product_id" headertext="product_id" />
<asp:templatefield headertext="name">
<edititemtemplate>
<asp:textbox id="TextBox1" runat="server" text="<%# Bind("category_name") %>"></asp:textbox>
</edititemtemplate>
<itemtemplate>
<asp:label id="Label1" runat="server" text="<%# Bind("category_name") %>"></asp:label>
<asp:label id="Label2" runat="server" text="<%# Eval("type") %>"></asp:label>
</itemtemplate>
</asp:templatefield>
<asp:boundfield datafield="degree" headertext="degree" />
<asp:boundfield datafield="package_type" headertext="package" />
<asp:templatefield headertext="price">
<edititemtemplate>
<asp:textbox id="TextBox2" runat="server" text="<%# Bind("price") %>"></asp:textbox>
</edititemtemplate>
<itemtemplate>
<asp:label id="Label3" runat="server" text="<%# Bind("price") %>"></asp:label>
</itemtemplate>
</asp:templatefield>
<asp:templatefield>
<footertemplate>
<asp:label id="Label3" runat="server"></asp:label>
</footertemplate>
<itemtemplate>
<asp:textbox id="TextBox2" runat="server" width="97px"></asp:textbox>
</itemtemplate>
</asp:templatefield>
<asp:templatefield>
<itemtemplate>
<asp:button id="Button3" runat="server" commandname="delete" cssclass="button" text="delete" />
</itemtemplate>
</asp:templatefield>
</columns>
</asp:gridview>
|
|
|
|
|
Hi,
For the GridViews RowDeleting event, access the ID and remove it.
Here is the steps to follow. After successful deletion re-bind the list to the GridView control.
1. For the delete button, set CommandArgument as the ID.
<asp:Button ID="btnDelete" runat="server" CommandName="delete" CommandArgument='<%#Eval("product_id")%'> />
2. For the RowDeleting event.
protected void GridView1_RowDeleting(object sender, GridViewDeleteEventArgs e)
{
Button btnDelete = (Button)GridView1.Rows[e.RowIndex].FindControl("btnDelete");
if (btnDelete != null)
{
int iProductID = Int32.Parse(btnDelete.CommandArgument);
if (Session["lstProduct"] != null)
{
List<Products> lstProducts = (List<Products> )Session["lstProduct"];
Products oProducts = lstProducts.Find(delegate(Products p) { return p.product_id == iProductID; });
if (oProducts != null)
{
//Give a message : record deleted successfully.
lstProducts.Remove(oProducts);
Session["lstProduct"] = lstProducts;
GridView1.DataSource = lstProducts;
GridView1.DataBind();
}
}
}
}
Hope it helps,
Thx,
Gayani
|
|
|
|
|
Products oProducts = lstProducts.Find(delegate(Products p)
what is delegate?I did't use product class.here is my code:
if (Session["basket"] == null)
{
List<string> pid = new List<string>();
pid.Add(productid.Trim());
Session["basket"] = pid;
}
else
{
((List<string>)Session["basket"]).Add(productid.Trim());
}
</string></string></string>
Button btnDelete = (Button)GridView1.Rows[e.RowIndex].FindControl("btnDelete");
I don't have RowIndex in my smart list.
modified on Friday, September 5, 2008 3:39 PM
|
|
|
|
|
Hi Gurus,
I have a tab container and under a tab panel I have datagrid .
When I dynamically populate the datagrid I find its height is more than the height of the tab panel / container. I do not get scrollbars for the tab panel. It gives me effect that my datagrid is overlapping my tab container.
How should I make datagrid remain inside the tab panel but still let it grow and in turn have scrollbars.
My code is
<ajaxToolkit:TabPanel ID="TabPanelResult" runat="server" HeaderText="TabPanel1" >
<HeaderTemplate>Result</HeaderTemplate>
<ContentTemplate>
<div align=center
<asp:datagrid id=dg_SearchResults runat="server" Width="262px" Font-Names="Verdana" Font-Size="7pt" PageSize="5" HorizontalAlign="Left" AutoGenerateColumns="False" AllowSorting="True" AllowCustomPaging="True" ForeColor="Black" CellPadding="2" BackColor="White" BorderWidth="1px" BorderStyle="Solid" BorderColor="#999999">
<FooterStyle Wrap="False" BackColor="#CCCCCC">
..
..
..
..
</TABLE>
<%--</asp:Panel>--%>
</div>
</ContentTemplate>
</ajaxToolkit:TabPanel>
</ajaxToolkit:TabContainer>
Please give me some feedback.
regards
vijay
|
|
|
|
|
Hi guys
I need to write the following sql query:
select * from table where field1 not in (select field2 from table2 where field3 like '%05/09/2008%' and sum (field3) < 1)
Basically I need to put a sum in the where statement, is it possible to do this?
thanks
The answers posted by me are suggestions only and cannot be used in anyway against me.
|
|
|
|
|
Dear .netman,
first of all you can not use aggregate functions (like sum, avg) without using Group by clause.
and another thing also you can not use aggregate functions in where clause. you have to use Having clause with group by clause.
select * from table where field1 not in (select field2 from table2 where field3 like '%05/09/2008%' gruop by field2 having sum (field3) < 1)
Regards,
Dilip Patel
|
|
|
|
|
try this
select * from table where field1 not in (select field2 from table2 where field3 like '%05/09/2008%' and (select top 1 sum(t1.field3) from table2 as t1 where t1.field3= table2.field3 group by t1.field3) < 1<br />
I Love T-SQL
"Don't torture yourself,let the life to do it for you."
If my post helps you kindly save my time by voting my post.
|
|
|
|
|
Hi
OK Im not sure how to write this query but Im going to explain because the code above works but it doesnt do what I want.
Basically I need to do check how many rows in another table contain the number 2 and match a certain date.
so something like
select * from table where field1 not in (select field2 from table2 where field3 like '%05/09/2008%' and sum number of fields containing '2' < 1)
any help on this would be great
thanks
The answers posted by me are suggestions only and cannot be used in anyway against me.
|
|
|
|
|
Which result you get from my query and which result you want to get?
I Love T-SQL
"Don't torture yourself,let the life to do it for you."
If my post helps you kindly save my time by voting my post.
|
|
|
|
|
Well to be honest i used the others guys query because I didnt understand what you mean by t1
The answers posted by me are suggestions only and cannot be used in anyway against me.
|
|
|
|
|
Anyway ,if you want post here result which u get from query and post result which you want.
I Love T-SQL
"Don't torture yourself,let the life to do it for you."
If my post helps you kindly save my time by voting my post.
|
|
|
|
|
It doesnt work, it just shows errors in the sql like incorrect syntax near '1'
thanks anyway!
The answers posted by me are suggestions only and cannot be used in anyway against me.
|
|
|
|
|
.netman wrote: thanks anyway!
No problem,it would be my pleasure if I could help you.
I Love T-SQL
"Don't torture yourself,let the life to do it for you."
If my post helps you kindly save my time by voting my post.
|
|
|
|
|
@ Blue_Boy
i think in the query u provided, something like,
SELECT * FROM table AS t1
is missing ....
Apurv
|
|
|
|
|
I have already specify table2 as t1 on my first post for this question.
I Love T-SQL
"Don't torture yourself,let the life to do it for you."
If my post helps you kindly save my time by voting my post.
|
|
|
|
|
<C1WebGrid:C1TemplateColumn HeaderText="StartDate">
<ItemStyle HorizontalAlign="Center"></ItemStyle>
<HeaderStyle HorizontalAlign="Center"></HeaderStyle>
<ItemTemplate>
<asp:TextBox ID="txtbxStartDate" runat="server" Style="width: 70px" ReadOnly="true" AutoPostBack="true" EnableViewState="true"></asp:TextBox>
<asp:ImageButton ID="imgStrtDt" runat="server" TabIndex="9" Height="21px" ImageUrl="../Images/calecder.jpg"
AlternateText="SelectDate" OnClientClick="return false;" />
<ajaxToolkit:CalendarExtender ID="clndrStrtDt" runat="server" Format="MM/dd/yyyy"
TargetControlID="txtbxStartDate" PopupButtonID="imgStrtDt">
</ajaxToolkit:CalendarExtender>
</ItemTemplate>
</C1WebGrid:C1TemplateColumn>
i have textbox and hidden button.......... <input id="hiddentxtDate" runat="server" type="hidden" />
when date get enter into textbox .....i want window popup
i want to call tht window popup in code behind.
how i will call?
|
|
|
|
|
1.
2.
3.
i have scripts like above and many more, whether it is possible to get image from these scripts.if possible then how?
thanks for any reply in advance.
|
|
|
|
|
I need to call an ASP fuction when closing the form. i have a HTML button that close the page is their any way i can call a function in the aspx.vb page?
Thanks
The Web Developer. Beirout-Lebanon
|
|
|
|
|
Use an asp.net button. After you run your code on the server use registerClientScriptBlock or whatever it to send the javascript to the client to close the window.
If you want to run a server side function from javasript you can use ajax to do that. The best method for that would depend on what version of asp.net you are working with.
I didn't get any requirements for the signature
|
|
|
|
|
I'm using ASP.NET 1.1 can it be done on 1.1 ?
The Web Developer. Beirout-Lebanon
|
|
|
|
|