Archive for July 26, 2006

Error : A potentially dangerous Request.Form value was detected from the client

This occurs when we try to post html code. The server will validate the postdata, if it find that its an HTML code, error something similar to this is shown. This actually helps to prevent running  malicious script. If you really want to post the html content add this to the page directive validateRequest=”false”. 

You can also do this from the web.config like this

<pages  validateRequest=”false” />


July 26, 2006 at 6:10 am 14 comments

Nested Gridview to show Master/Details relationship in ASP.NET 2.0

This will help you to nest grdiviews inside ASP.NET. There may be many ways to do this, but this is my way( May not be the best, let me know if you have any other 🙂 ).

1. First drop a gridview in to the page, also set its DataKeyNames to your primary key

2. Add a new template column to this gridview.

3. Place another gridview inside this template column.

the code for the termplate column may look like this

<asp:TemplateField HeaderText=”Heading”>
<asp:TextBox ID=”TextBox3″ runat=”server”></asp:TextBox>
<asp:GridView ID=”GridView1″ runat=”server” DataSource='<%# GetTrasnl(Convert.ToInt32(Eval(“pId”))) %>’ AutoGenerateColumns=”False” CellPadding=”4″ ForeColor=”Black” GridLines=”Vertical” BackColor=”White” BorderColor=”#DEDFDE” BorderStyle=”None” BorderWidth=”1px”>
<FooterStyle BackColor=”#CCCC99″ />
<asp:BoundField DataField=”language” HeaderText=”Language” />
<asp:BoundField DataField=”uName” HeaderText=”Translator” />
<RowStyle BackColor=”#F7F7DE” />
<SelectedRowStyle BackColor=”#CE5D5A” Font-Bold=”True” ForeColor=”White” />
<PagerStyle BackColor=”#F7F7DE” ForeColor=”Black” HorizontalAlign=”Right” />
<HeaderStyle BackColor=”#6B696B” Font-Bold=”True” ForeColor=”White” />
<AlternatingRowStyle BackColor=”White” />

This child gridview has to show the content based on the primary of the row thats binded to main gridview.

Here in my case “pId” is the primary key. The nesting happens here

<asp:GridView ID=”GridView1″ runat=”server” DataSource='<%#GetTrasnl(Convert.ToInt32(Eval(“pId”))) %>’

what I have done is that, I have called function “GetTrasnl” and passed the primary key to that function. This function will return a datatable. So each time a row is bound to the main gridview, the child gridview is also bound with the corresponding values.

The functions is like this

Public Function GetTrasnl(ByVal prgId As Integer) As DataTable


End Function

Please post your comments if you have any

July 26, 2006 at 5:02 am 32 comments

Top Clicks

  • None


July 2006
    Aug »

Recent Posts


Blog Stats

  • 93,417 hits