Hi Sck10,
Welcome.
I think for your scenario, the DropDownList control is necessary because
we need it to pickup all the sub item list from DataBase and mapped the
curernt row's subitem index to it's Text property... However, if you do
need to avoid diplaying the text through DropDownList, we can consider put
another separate Label control in the TemplateColumn' s Itemtemplate
together with the DropDownList, and use the Label control's PreRender event
to set Text value from the DropDownList's Selected Text ..... (the
dropDownList's Visible is set to False...). below is some sample code
snippet:
<ItemTemplate >
<asp:DropDownLi st ID="lstCategory " runat="server"
DataSourceID="S qlDataSource2" DataTextField=" CategoryName"
DataValueField= "CategoryID " SelectedValue=' <%#
Bind("CategoryI D") %>' Visible="False" >
</asp:DropDownLis t>
<asp:Label ID="Label1" runat="server"
OnPreRender="La bel1_PreRender" Text="Label"></asp:Label>
</ItemTemplate>
</asp:TemplateFie ld>
protected void Label1_PreRende r(object sender, EventArgs e)
{
Label lbl = sender as Label;
DropDownList lst = lbl.NamingConta iner.FindContro l("lstCategory" )
as DropDownList;
if (lst != null)
{
lbl.Text = lst.SelectedIte m.Text;
}
}
Hope helps. Thanks,
Steven Cheng
Microsoft Online Support
Get Secure!
www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
--------------------
| From: "sck10" <sc***@online.n ospam>
| Subject: GridView with dropdown: asp.net 2.0
| Date: Thu, 22 Dec 2005 17:43:45 -0600
| Lines: 55
| X-Priority: 3
| X-MSMail-Priority: Normal
| X-Newsreader: Microsoft Outlook Express 6.00.2800.1506
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1506
| Message-ID: <eZ************ **@tk2msftngp13 .phx.gbl>
| Newsgroups: microsoft.publi c.dotnet.framew ork.aspnet
| NNTP-Posting-Host: 189.202.185.135 .in-addr.arpa 135.185.202.189
| Path: TK2MSFTNGXA02.p hx.gbl!TK2MSFTN GP08.phx.gbl!tk 2msftngp13.phx. gbl
| Xref: TK2MSFTNGXA02.p hx.gbl
microsoft.publi c.dotnet.framew ork.aspnet:3666 82
| X-Tomcat-NG: microsoft.publi c.dotnet.framew ork.aspnet
|
| Hello,
|
| I am using the following in a GridView. Currently, I am using a dropdown
| that pulls the Name of the person, given the Employee ID. I am doing this
| in both the ItemTemplate and the EditTemplate. This makes sense for the
| EditTemplate becuase the user can then change the Employee using the
| dropdown box. What I am trying to figure out is how to show the Employee
| Name in the ItemTemplate without having to use a DropDownList Box. Is
there
| a way to reference the stored procedure (below) without using a
| dropdownlist?
| --
| Thanks in advance,
|
| sck10
|
|
| <!-- Datasource: Dropdownlist: Contact Employee ID -->
| <asp:SqlDataSou rce ID="dsEmployeeI DDLL" runat="server"
| ConnectionStrin g="<%$ ConnectionStrin gs:cnnSvctech %>"
| SelectCommand=" sp_web_LabTrack " SelectCommandTy pe="StoredProce dure">
| <SelectParamete rs>
| <asp:Paramete r DefaultValue="F indContactDLL" Name="strParm01 "
| Type="String" />
| <asp:Paramete r DefaultValue="N oParameter" Name="strParm02 "
| Type="String" />
| <asp:Paramete r DefaultValue="N oParameter" Name="strParm03 "
| Type="String" />
| <asp:Paramete r DefaultValue="N oParameter" Name="strParm04 "
| Type="String" />
| </SelectParameter s>
| </asp:SqlDataSour ce>
|
| <asp:TemplateFi eld
| HeaderText="Act ivity"
| HeaderStyle-Font-Bold="true"
| HeaderStyle-ForeColor="blac k"
| ItemStyle-Width="70%"
| ItemStyle-VerticalAlign=" Top" >
| <ItemTemplate >
| <asp:DropDownLi st id="ddlEmployee ID1" DataSourceID="d sEmployeeIDDLL"
| Runat="Server"
| DataTextField=" ContactName" DataValueField= "EmployeeID " SelectedValue=' <%#
| Bind("EmployeeI D") %>'/>
| <%--<asp:Label ID="lblEmployee ID" Text='<%# Eval("EmployeeI D") %>'
| Runat="Server"/>--%>
| </ItemTemplate>
| <EditItemTempla te>
| <asp:DropDownLi st id="ddlEmployee ID" DataSourceID="d sEmployeeIDDLL"
| Runat="Server"
| DataTextField=" ContactName" DataValueField= "EmployeeID " SelectedValue=' <%#
| Bind("EmployeeI D") %>'/>
| </EditItemTemplat e>
| </asp:TemplateFie ld>
|
|
|