Hi..
i am using 4 gridviews in one page and that is showing latest updates of months on one gridview the image button is working and postback url for it is also working but for another gridview postbackurl gives error.
this is my aspx page code
<asp:Panel ID="pnlstud" runat="server">
<asp:Label ID="lblenroll" runat="server" Text="Enter Enrollment No:"></asp:Label>
<asp:TextBox ID="txtenroll"
runat="server" AutoPostBack="True"></asp:TextBox> <asp:Button ID="btnsub"
runat="server" Text="Submit" CssClass="btn btn-primary" onclick="btnsub_Click"/>
<br />
<asp:Label ID="lblmsg" runat="server" Visible="false" Font-Size="15px" ForeColor="#CC0000"></asp:Label>
</asp:Panel>
<asp:Panel ID="pnlstudentsearch" runat="server" Visible="false" ScrollBars="Auto" Width="100%">
<asp:GridView ID="GridView5" GridLines="None" EmptyDataText="No Data Found" CssClass="table table-striped" runat="server">
<Columns>
<asp:TemplateField HeaderText="View">
<ItemTemplate>
<asp:ImageButton ID="ImageButton1" CommandName="View" runat="server"
ImageUrl="~/images/view.png" ToolTip="View" Height="20px" Width="20px"
PostBackUrl='<%# "Appli_Result.aspx?id="+Eval("Appli_Id") %>'
CausesValidation="False" />
</ItemTemplate>
</asp:TemplateField>
</Columns>
<HeaderStyle ForeColor="#1876AF" />
</asp:GridView>
</asp:Panel>
<asp:Panel ID="Panel1" Width="100%" ScrollBars="Auto" CssClass="table-responsive" runat="server">
<h2 style="color: #1876AF">Latest Applications</h2>
<asp:GridView ID="GridView1" GridLines="None" EmptyDataText="No Data Found" CssClass="table table-striped" runat="server">
<Columns>
<asp:TemplateField HeaderText="View">
<ItemTemplate>
<asp:ImageButton ID="imgbtnview" CommandName="View" runat="server"
ImageUrl="~/images/view.png" ToolTip="View" Height="20px" Width="20px"
PostBackUrl='<%# "Appli_Result.aspx?id="+Eval("Appli_Id") %>'
/>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="Appli Id">
<ItemTemplate>
<asp:Label ID="lblappliid" runat="server" Text='<%#Eval("Appli_Id") %>'/>
</ItemTemplate>
</asp:TemplateField>
</Columns>
<HeaderStyle ForeColor="#1876AF" />
</asp:GridView>
and this is c# code
protected void Page_Load(object sender, EventArgs e)
{
Griddata();
}
protected void Griddata()
{
conn.Open();
qry = "SELECT Appli_Id AS [Application Id],Student_Name As [Student Name],Course,Specialization,University,Fees_Offered AS [Fees Offered],Fees_Rec AS [Fees Received] FROM App_Master WHERE MONTH(Form_Date)=MONTH(GETDATE()) ";
SqlCommand cmd = new SqlCommand(qry, conn);
SqlDataReader dr = cmd.ExecuteReader();
GridView1.DataSource = dr;
GridView1.DataBind();
conn.Close();
}
protected void Gridstud()
{
conn.Open();
qry = "Select Appli_Id,Student_Name,Uni_Enroll_No,Course,Specialization,University,Business_Pro,Service_Pro from App_Master where Uni_Enroll_No='"+txtenroll.Text+"'";
SqlCommand cmd = new SqlCommand(qry, conn);
SqlDataReader dr = cmd.ExecuteReader();
GridView5.DataSource = dr;
GridView5.DataBind();
conn.Close();
}
protected void btnsub_Click(object sender, EventArgs e)
{
conn.Open();
qry = "SELECT * FROM App_Master WHERE Uni_Enroll_No = '" + txtenroll.Text + "'";
SqlCommand cmd = new SqlCommand(qry, conn);
SqlDataReader dr = cmd.ExecuteReader();
if (dr.Read() == true)
{
pnlstudentsearch.Visible = true;
conn.Close();
Gridstud();
lblmsg.Visible = false;
}
else
{
pnlstudentsearch.Visible = false;
lblmsg.Visible = true;
lblmsg.Text = "Enrollment No. does not exists.";
}
dr.Close();
}
}
my error is this
DataBinding: 'System.Data.Common.DataRecordInternal' does not contain a property with the name 'Appli_Id'.
Line 49: <asp:TemplateField HeaderText="View">
Line 50: <ItemTemplate>
Line 51: <asp:ImageButton ID="imgbtnview" CommandName="View" runat="server"
Line 52: ImageUrl="~/images/view.png" ToolTip="View" Height="20px" Width="20px"
Line 53: PostBackUrl='<%# "Appli_Result.aspx?id="+Eval("Appli_Id") %>'
plz help me....