Click here to Skip to main content
16,016,770 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
<pre lang="xml">I table viewyn and dept_letter. primary ket l_no

]&lt;asp:TemplateField HeaderText=&quot;l_no&quot;&gt;
&lt;ItemTemplate&gt;
&lt;asp:LinkButton runat=&quot;server&quot; ID =&quot;l_no&quot; Text=&#39;&lt;%# Eval(&quot;l_no&quot;) %&gt;&#39; OnClick=&quot;l_no_Click&quot; /&gt;
&lt;/ItemTemplate&gt;
&lt;/asp:TemplateField&gt;

protected void l_no_Click(object sender, EventArgs e)
{
// Fetch the customer id
LinkButton lb = sender as LinkButton;
string custID = lb.Text;
lblCustValue.Text = custID;
// Connection
string constr = System.Web.Configuration.WebConfigurationManager.ConnectionStrings[&quot;JAPITConnectionString&quot;].ConnectionString;
string sql = &quot;SELECT * FROM Letter_dept WHERE l_no= @l_no&quot;;
SqlConnection connection = new SqlConnection(constr);
connection.Open();
SqlCommand cmd = new SqlCommand(sql, connection);
cmd.Parameters.AddWithValue(&quot;@l_no&quot;, l_no);
cmd.CommandType = CommandType.Text;

SqlDataReader dr = cmd.ExecuteReader();
// Bind the reader to the GridView
// You can also use a lighter control
// like the Repeater to display data
GridView2.DataSource = dr;
GridView2.DataBind();
connection.Close();
// Show the modalpopupextender
ModalPopupExtender1.Show();

}


Error is coming Error 1 The name &#39;l_no&#39; does not exist in the current context</pre>
Posted

cmd.Parameters.AddWithValue("@l_no", l_no)


you are passing value as l_no but that is variable or any thing you are not mentioned that.so defined that thing
 
Share this answer
 
Comments
Shinand 15-Dec-11 8:35am    
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">

<asp:ScriptManager ID="ScriptManager1" runat="server">



<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<contenttemplate>

<asp:GridView ID="GridView1" runat="server"
AutoGenerateColumns="False" AllowPaging="True" DataSourceID="SqlDataSource1"
onselectedindexchanged="GridView1_SelectedIndexChanged" >
<columns>

<asp:TemplateField HeaderText="l_no">
<itemtemplate>
<asp:LinkButton runat="server" ID ="l_no" Text='<%# Eval("l_no") %>' OnClick="l_no_Click" />



<asp:BoundField DataField="nam_dep" HeaderText="nam_dep"
SortExpression="nam_dep" />
<asp:BoundField DataField="no_deo" HeaderText="no_deo"
SortExpression="no_deo" />
<asp:BoundField DataField="no_mon" HeaderText="no_mon"
SortExpression="no_mon" />
<asp:BoundField DataField="le_yn" HeaderText="le_yn"
SortExpression="le_yn" />





<asp:BoundField DataField="dd_yn" HeaderText="dd_yn" SortExpression="dd_yn" />


<asp:ModalPopupExtender ID="ModalPopupExtender1" runat="server"
TargetControlID="btnShowModalPopup"
PopupControlID="divPopUp"
BackgroundCssClass="popUpStyle"
PopupDragHandleControlID="panelDragHandle"
DropShadow="true">
<asp:Button runat="server" ID="btnShowModalPopup" style="display:none"/>
<div class="popUpStyle" id="divPopUp" style="display:none;">
<asp:Panel runat="Server" ID="panelDragHandle" CssClass="drag">
Hold here to Drag this Box

<asp:Label runat="server" ID="lblText" Text="CustomerID: ">
<asp:Label ID="lblCustValue" runat="server">
<asp:GridView ID="GridView2" runat="server">

<asp:Button ID="btnClose" runat="server" Text="Close" />
<br />
</div>



<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:JAPITConnectionString %>"
SelectCommand="SELECT * FROM [viewyn]">
I have less knowledge this i want l_no please help me .thank for help

<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">

<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>


<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>

<asp:GridView ID="GridView1" runat="server"
AutoGenerateColumns="False" AllowPaging="True" DataSourceID="SqlDataSource1"
onselectedindexchanged="GridView1_SelectedIndexChanged" >
<Columns>

<asp:TemplateField HeaderText="l_no">
<ItemTemplate>
<asp:LinkButton runat="server" ID ="l_no" Text='<%# Eval("l_no") %>' OnClick="l_no_Click" />
</ItemTemplate>
</asp:TemplateField>

<asp:BoundField DataField="nam_dep" HeaderText="nam_dep"
SortExpression="nam_dep" />
<asp:BoundField DataField="no_deo" HeaderText="no_deo"
SortExpression="no_deo" />
<asp:BoundField DataField="no_mon" HeaderText="no_mon"
SortExpression="no_mon" />
<asp:BoundField DataField="le_yn" HeaderText="le_yn"
SortExpression="le_yn" />





<asp:BoundField DataField="dd_yn" HeaderText="dd_yn" SortExpression="dd_yn" />
</Columns>
</asp:GridView>
<asp:ModalPopupExtender ID="ModalPopupExtender1" runat="server"
TargetControlID="btnShowModalPopup"
PopupControlID="divPopUp"
BackgroundCssClass="popUpStyle"
PopupDragHandleControlID="panelDragHandle"
DropShadow="true"> </asp:ModalPopupExtender>
<asp:Button runat="server" ID="btnShowModalPopup" style="display:none"/>
<div class="popUpStyle" id="divPopUp" style="display:none;">
<asp:Panel runat="Server" ID="panelDragHandle" CssClass="drag">
Hold here to Drag this Box
</asp:Panel>
<asp:Label runat="server" ID="lblText" Text="CustomerID: "></asp:Label>
<asp:Label ID="lblCustValue" runat="server"></asp:Label>
<asp:GridView ID="GridView2" runat="server">
</asp:GridView>
<asp:Button ID="btnClose" runat="server" Text="Close" />
<br />
</div>

</ContentTemplate>
</asp:UpdatePanel>
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:JAPITConnectionString %>"
SelectCommand="SELECT * FROM [viewyn]"></asp:SqlDataSource>
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900