如何在网格视图中显示名称 [英] how to display name in in grid view

查看:84
本文介绍了如何在网格视图中显示名称的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在网格视图中显示名称..i在我的表单中有下拉但是当我从下拉列表中选择项目时,id被插入数据库但是当我加载网格时,网格中显示相同的id ..如何在我的网格视图中获取该特定ID的名称...我是这个领域的新手请帮助我



< asp:GridView ID = GridView1runat =serverAutoGenerateColumns =false

onrowediting =GridView1_RowEditingonsorting =GridView1_Sorting

DataKeyNames =pk_crm_leadidWidth =722pxAllowPaging =True

BorderStyle =RidgeCssClass =TDClassGridLines =水平

onpageindexchanging =GridView1_PageIndexChangingCellPadding =2>

< columns> < asp:TemplateField HeaderText =pk_crm_leadidVisible =false>

< itemtemplate>

< asp:Label ID =pk_crm_leadidrunat =服务器Text ='<%#Bind(pk_crm_leadid)%>'>







< asp:TemplateField HeaderText =客户名称>

< itemtemplate>

< asp:Label ID =txtpartynamerunat =server Text ='<%#Bind(crm_customername)%>'>







< asp:TemplateField HeaderText =地址>

< itemtemplate>

< asp:Label ID =txt add1runat =serverText ='<%#Bind(crm_address)%>'>







< asp:TemplateField HeaderText =Telephone>

< itemtemplate>

< asp:Label ID =txttel runat =serverText ='<%#Bind(crm_telephone)%>'>







< asp:TemplateField HeaderText =Fax No>

< itemtemplate>

< asp:Label ID =txtfaxnorunat =serverText ='<%#Bind(crm_faxno)%>'>







< asp:T emplateField HeaderText =Mobile>

< itemtemplate>

< asp:Label ID =txtmblrunat =serverText ='<%# Bind(crm_mobile)%>'>







< asp:TemplateField HeaderText =电子邮件ID>

< itemtemplate>

< asp:标签ID =txtemailidrunat =serverText ='<%#Bind (crm_emailid)%>'>







< asp:TemplateField HeaderText = 网站>

< itemtemplate>

< asp:标签ID =txtwebsiterunat =serverText ='<%#Bind( crm_website )%>'>







< asp:TemplateField HeaderText =联系人姓名>

< itemtemplate>

< asp:Label ID =txtcontactnamerunat =serverText ='<%#Bind(crm_contactname )%>'>







< asp:TemplateField HeaderText =分配给 >

< itemtemplate>

< asp:Label ID =drdnlist_emprunat =serverText ='<%#Bind(fk_crm_assignto) %>'>









< asp: TemplateField Head erText =编辑>

< itemtemplate>

< asp:LinkBut​​ton ID =lnkbtneditrunat =serverCommandName =edit>编辑



<% - < edititemtemplate>

< asp:LinkBut​​ton ID =lnkbtncancelrunat =serverCommandName = 取消>取消

< asp:LinkBut​​ton ID =lnkbtnupdaterunat =serverCommandName =Update>更新

- %>











这是我的网格视图,这是我想要绑定empname的代码(< asp:Label ID =drdnlist_emprunat =serverText ='<%#Bind(fk_crm_assignto)%>'> )但是当我是joini时我的查询收到错误



这是我用来填充网格SELECT a.pk_crm_leadid,a.crm_customername,a.crm_address,a.crm_telephone的选择查询, a.crm_faxno,a.crm_mobile,a.crm_emailid,a.crm_website,a.crm_contactname,a.fk_crm_assignto,b.empname FROM crm_lead a,employee b其中b.empno = a.fk_crm_assignto

how to display name in in grid view ..i have drop down in my form but when i select the item from drop down the id is inserted into database but when i am loading the grid the same id is displayed in the grid ..how to get the name of that particular id in my grid view ...i am new to this field please help me

<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="false"
onrowediting="GridView1_RowEditing" onsorting="GridView1_Sorting"
DataKeyNames ="pk_crm_leadid" Width="722px" AllowPaging="True"
BorderStyle="Ridge" CssClass="TDClass" GridLines="Horizontal"
onpageindexchanging="GridView1_PageIndexChanging" CellPadding="2">
<columns> <asp:TemplateField HeaderText="pk_crm_leadid" Visible = "false">
<itemtemplate>
<asp:Label ID="pk_crm_leadid" runat="server" Text='<%# Bind("pk_crm_leadid") %>'>



<asp:TemplateField HeaderText="Customer Name" >
<itemtemplate>
<asp:Label ID="txtpartyname" runat="server" Text='<%# Bind("crm_customername") %>'>



<asp:TemplateField HeaderText="Address " >
<itemtemplate>
<asp:Label ID="txtadd1" runat="server" Text='<%# Bind("crm_address") %>'>



<asp:TemplateField HeaderText="Telephone " >
<itemtemplate>
<asp:Label ID="txttel" runat="server" Text='<%# Bind("crm_telephone") %>'>



<asp:TemplateField HeaderText="Fax No" >
<itemtemplate>
<asp:Label ID="txtfaxno" runat="server" Text='<%# Bind("crm_faxno") %>'>



<asp:TemplateField HeaderText="Mobile" >
<itemtemplate>
<asp:Label ID="txtmbl" runat="server" Text='<%# Bind("crm_mobile") %>'>



<asp:TemplateField HeaderText="Email Id" >
<itemtemplate>
<asp:Label ID="txtemailid" runat="server" Text='<%# Bind("crm_emailid") %>'>



<asp:TemplateField HeaderText="Website" >
<itemtemplate>
<asp:Label ID="txtwebsite" runat="server" Text='<%# Bind("crm_website") %>'>



<asp:TemplateField HeaderText="Contact Name" >
<itemtemplate>
<asp:Label ID="txtcontactname" runat="server" Text='<%# Bind("crm_contactname") %>'>



<asp:TemplateField HeaderText="Assign To" >
<itemtemplate>
<asp:Label ID="drdnlist_emp" runat="server" Text='<%# Bind("fk_crm_assignto") %>'>




<asp:TemplateField HeaderText="Edit">
<itemtemplate>
<asp:LinkButton ID="lnkbtnedit" runat="server" CommandName="edit">Edit

<%--<edititemtemplate>
<asp:LinkButton ID="lnkbtncancel" runat="server" CommandName="Cancel">Cancel
<asp:LinkButton ID="lnkbtnupdate" runat="server" CommandName="Update">Update
--%>





this is my grid view and this is the code in which i want to bind empname (<asp:Label ID="drdnlist_emp" runat="server" Text='<%# Bind("fk_crm_assignto") %>'>) but when i am joining the query am getting error

this is the select query i am using to fill grid SELECT a.pk_crm_leadid,a.crm_customername ,a.crm_address,a.crm_telephone,a.crm_faxno,a.crm_mobile,a.crm_emailid,a.crm_website,a.crm_contactname,a.fk_crm_assignto,b.empname FROM crm_lead a,employee b where b.empno = a.fk_crm_assignto

推荐答案

选择查询没有列 empname 但是你试图用gridview绑定它



例如;

The select query doesn't have a column empname but you are trying to bind it with gridview

For eg;
select column1,column2 from tablename



如果你有这样的查询,那么标记应该是这样的:


if you have query like this then mark up should be like this:

<asp:Label ID="label1" runat="server" Text='<%#Eval("column1") %>'></asp:Label>
<asp:Label ID="label2" runat="server" Text='<%#Eval("column2") %>'></asp:Label>


它可以帮到你:



< asp:repeater id =Repeater1runat =serverxmlns:asp =#unknown>

< headertemplate>



SNo

手机号码

用户

部门

分配日期

短号

信用额度

城市

行动



< itemtemplate>

<%#Eval(SNo)% >

<%#Eval(MobileNo)%>

<%#Eval(Name)%>

<%#Eval(Department)%>

<%#Eval(AssignDate)%>

<%#Eval(ShortNo )%>

<%#Eval(CreditLimit)%>

<%#Eval(城市 )%>



<% - - %> Del



 



<% - - %>

编辑





< footertemplate>




it may help you:

<asp:repeater id="Repeater1" runat="server" xmlns:asp="#unknown">
<headertemplate>

SNo
Mobile No.
User
Department
Assign Date
Short No.
Credit Limit
City
Action

<itemtemplate>
<%# Eval("SNo")%>
<%# Eval("MobileNo")%>
<%# Eval("Name")%>
<%# Eval("Department")%>
<%# Eval("AssignDate")%>
<%# Eval("ShortNo")%>
<%# Eval("CreditLimit")%>
<%# Eval("City")%>

<%----%>Del

 

<%-- --%>
Edit


<footertemplate>



这篇关于如何在网格视图中显示名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆