|
Please add the Runat= server tag in your Grid view and run ur application.
Regards,
Satips.
|
|
|
|
|
I think runat=server has to be added in form control not in gridview.
Apurva Kaushal
|
|
|
|
|
Yes. Runat=server has to be added in the form Control.
Regards,
Satips.
|
|
|
|
|
Thank you all for the quick response!!!
my Form tag & Gridview both contains "runat=server" tag in it! ~!!! but no use!
grrrrrrr!
|
|
|
|
|
I think there would be some mismatch can you show us the form tag code?
Apurva Kaushal
|
|
|
|
|
yes, here is my form tag code:
<form id="form1" runat="server" style="width: 100%; height: 75%;">
<div>
<table border="0" width="100%">
<tr>
<td style="width: 5%"></td>
<td valign="top" style="width:20%;"><font face="Verdana" size="2">
<asp:Label ID="lblCompany" Width="100%" runat="server">Company</asp:Label></font></td>
<td valign="top" width="70%">
<asp:Label ID="lblCompany1" runat="server"></asp:Label></td>
<td width="5%"></td>
</tr>
<tr>
<td style="width: 5%"></td>
<td valign="top" style="width:20%;"><font face="Verdana" size="2">
<asp:Label ID="lblAddress" Width="100%" runat="server">Address</asp:Label></font></td>
<td valign="top" width="70%">
<asp:Label ID="lblAddress1" runat="server" TextMode="MultiLine"></asp:Label></td>
<td width="5%"></td>
</tr>
<tr>
<td style="width: 5%"></td>
<td valign="top" style="width:20%;"><font face="Verdana" size="2">
<asp:Label ID="lblTelephone" Width="100%" runat="server">Telephone</asp:Label></font></td>
<td valign="top" width="70%">
<asp:Label ID="lblTelephone1" runat="server"></asp:Label></td>
<td width="5%"></td>
</tr>
<tr>
<td style="width: 5%"></td>
<td valign="top" style="width:20%;"><font face="Verdana" size="2">
<asp:Label ID="lblFax" Width="100%" runat="server">Fax</asp:Label></font></td>
<td valign="top" width="70%">
<asp:Label ID="lblFax1" runat="server"></asp:Label></td>
<td width="5%"></td>
</tr>
<tr>
<td style="width: 5%"></td>
<td valign="top" style="width:20%;"><font face="Verdana" size="2">
<asp:Label ID="lblEmail" Width="100%" runat="server">Email</asp:Label></font></td>
<td valign="top" width="70%">
<asp:Label ID="lblEmail1" runat="server"></asp:Label></td>
<td width="5%"></td>
</tr>
</table>
<br /><br />
<asp:GridView ID="myGridView" runat="server" Width="483px" CellPadding="4" ForeColor="#333333" AutoGenerateColumns="False" DataSourceID="AccessDataSource1">
<Columns>
<asp:BoundField DataField="Sno" HeaderText="SNo" SortExpression="Sno" />
<asp:BoundField DataField="Partno" HeaderText="PartNo" SortExpression="Partno" />
<asp:BoundField DataField="mfg" HeaderText="Manufacturer" SortExpression="mfg" />
<asp:BoundField DataField="qty" HeaderText="Quantity" SortExpression="qty" />
<asp:BoundField DataField="price" HeaderText="Price" SortExpression="price" />
</Columns>
<FooterStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
<RowStyle BackColor="#EFF3FB" />
<EditRowStyle BackColor="#2461BF" />
<SelectedRowStyle BackColor="#D1DDF1" Font-Bold="True" ForeColor="#333333" />
<PagerStyle BackColor="#2461BF" ForeColor="White" HorizontalAlign="Center" />
<HeaderStyle BackColor="#507CD1" Font-Bold="True" ForeColor="White" />
<AlternatingRowStyle BackColor="White" />
</asp:GridView>
<asp:AccessDataSource ID="AccessDataSource1" runat="server" DataFile="~/App_Data/db1.mdb"
SelectCommand="SELECT [Sno], [Partno], [mfg], [qty], [price] FROM [RfqInfo]"></asp:AccessDataSource>
<br />
<br />
<table border="0" style="width: 100%">
<tr>
<td style="width: 5%"></td>
<td valign="top" style="width:20%;"><font face="Verdana" size="2">
<asp:Label ID="lblComments" Width="100%" runat="server">Comments</asp:Label></font></td>
<td valign="top" width="70%">
<asp:Label ID="lblComments1" runat="server" TextMode="MultiLine"></asp:Label></td>
<td width="5%"></td>
</tr>
<tr>
<td style="width: 5%; height: 26px;"></td>
<td valign="top" style="width:10%; height: 26px;"><font face="Verdana" size="2">
<asp:Button ID="btnSubmit" Width="100%" runat="server" Text="submit" OnClick="btnSubmit_Click"></asp:Button></font></td>
<td width="5%" style="height: 26px"></td>
</tr>
</table>
<asp:Button ID="BtnExport" runat="server" OnClick="BtnExport_Click"
Text="Export to Excel" />
</div>
</form>
|
|
|
|
|
This peace of code works fine for me. I executed that one and is performing well.
Apurva Kaushal
|
|
|
|
|
hmm...but whats wrong from my side:
I executed it again but still the same error persists
here is the error::
Control 'myGridView' of type 'GridView' must be placed inside a form tag with runat=server.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Web.HttpException: Control 'myGridView' of type 'GridView' must be placed inside a form tag with runat=server.
Source Error:
Line 63: System.IO.StringWriter stringWrite = new System.IO.StringWriter();
Line 64: System.Web.UI.HtmlTextWriter htmlWrite = new HtmlTextWriter(stringWrite);
Line 65: myGridView.RenderControl(htmlWrite);
Line 66: Response.Write(stringWrite.ToString());
Line 67: Response.End();
|
|
|
|
|
its showing the error at Line 65.
|
|
|
|
|
In order to overcome the error, We have to override the below function.
public override void VerifyRenderingInServerForm(Control control)
{
}
Regards,
Jay
|
|
|
|
|
Cool stuff man... I will rate this...
|
|
|
|
|
Thanks (For Nellai Website Too)
-- modified at 5:45 Wednesday 13th June, 2007
Regards,
Jay
|
|
|
|
|
DKalepu wrote: myGridView.RenderControl(htmlWrite);
You cannot render the GridView Control into HTML directly. Use DataGrid.
May be Jay_se is correct. But I haven't tried that before. We also had this issue before and we solve that using DataGrid. We can used JavaScript get the HTML String of the GridView and do the same.
|
|
|
|
|
Hi,
Venkatesh MookkanYou cannot render the GridView Control into HTML directly.
We Can do Vankat. It works fine too.
Regards,
Jay
|
|
|
|
|
If it works fine, then no problem for me man..
Thanks...
|
|
|
|
|
Hi, Thank you very much for the help Jay..
That piece of code solved my problem.....
Thank you so much once again to all of you for helping on my problem/
|
|
|
|
|
Asp.net
=======
I have master page.
when i redirect to different pages in master page, page refeshes.
is there any why i could do
--> page is redirected.
--> client doesnot feel refresh effect
server.transfer ("filename") gives error
Thank you
vijaya
vijaya
|
|
|
|
|
How to call login page on session timeout,pls send me code for this.
Thank you.
|
|
|
|
|
Redirect the user to the login page using response.redirect method.
Apurva Kaushal
|
|
|
|
|
This is ok,but on which event should i write this code pls reply.
|
|
|
|
|
In the load event of the page you can check for the session and then if it is not available then user should be redirected to login page.
Apurva Kaushal
|
|
|
|
|
Hi,
if(session["LoginName"] == null)
{
response.redirect("Loginpage.aspx");
}
I hope this will help you.
Thanks and Regards,
Chetan Ranpariya
|
|
|
|
|
Go with Response.Redirect("urpage.aspx");
Regards,
Satips.
|
|
|
|
|
hi, my last post i have already find out how to add the record. and i manage to add the record into the Movie Table. now i hav another problem which is in my form the actor n director have a dropdown list for user to choose n if in the dropdown list the the actor cannot be found the user can type in the name. how am i goin to do the code to detact if the dropdown list is empty then go to the textbox n add the name that they have key in? below is my code which i have done so far. Thanks a lot 4 the help
Protected Sub Submit_Click(ByVal sender As Object, ByVal e As System.EventArgs)
Dim Moviename
Dim Actorname
Dim Director
Dim Language
Dim Numberofdisc
Dim Studio
Dim ReleaseDate
Dim Price
Dim Quantity
Dim sql
Dim asql
Dim DBconn As New OleDb.OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;data source=" & Server.MapPath("dvd_rental.mdb"))
DBconn.Open()
Moviename = Request.Form("txtmovieName")
Actorname = Request.Form("txtActorname")
Director = Request.Form("txtDirector")
Language = Request.Form("txtLanguage")
Numberofdisc = Request.Form("txtNoofdisc")
Studio = Request.Form("txtStudio")
ReleaseDate = Request.Form("txtReleaseDate")
Price = Request.Form("txtPrice")
Quantity = Request.Form("txtQuantity")
sql = "INSERT INTO Movie(MovieName, MovieLanguage, Numberofdisc, Studio, ReleaseDate, Price, Quantity) "
sql = sql & "VALUES('" & Moviename & "'"
sql = sql & ",'" & Language & "'"
sql = sql & ",'" & Numberofdisc & "'"
sql = sql & ",'" & Studio & "'"
sql = sql & ",'" & ReleaseDate & "'"
sql = sql & ",'" & Price & "'"
sql = sql & ",'" & Quantity & "')"
asql = "INSERT INTO Actor(Actor Name)VALUES('" & Actorname & "')"
Dim dbq As New OleDb.OleDbCommand
dbq.CommandType = CommandType.Text
dbq.CommandText = asql
dbq.Connection = DBconn
dbq.ExecuteNonQuery()
Dim dbquery As New OleDb.OleDbCommand
dbquery.CommandType = CommandType.Text
dbquery.CommandText = sql
dbquery.Connection = DBconn
dbquery.ExecuteNonQuery()
DBconn.Close()
DBconn = Nothing
Response.Redirect("WebAddResult.aspx")
End Sub
function Table1_onclick() {
}
function Text1_onclick() {
}
Add new DVD Record | | | |
DVD Title: |
|
Actor: |
DataTextField="Actor_Name" DataValueField="Actor_Name" Width="132px">
SelectCommand="SELECT [Actor Name] AS Actor_Name FROM [Actor]">
|
Director: |
DataTextField="Director_Name" DataValueField="Director_Name">
SelectCommand="SELECT [Director Name] AS Director_Name FROM [Director]">
| Language: | | Number of Disc: | |
Studio: |
| Release Date: | |
Price: |
|
Quantity: |
| | |
| |
ling
ling
|
|
|
|
|
Hi,
What to do with the code?
Any question or error?
Thanks and Regards,
Chetan Ranpariya
|
|
|
|