GridView生成在html里的table问题

joewang1986 2008-11-27 08:53:38
Gridview做出的表格,在浏览器中查看源代码的时候,是用table来显示的,那么我能不能在gridview里面添加某些信息,使得显示出来的表格,带有id属性呢?就是类似于<tr id =“。。”>,
先谢谢大家了。
...全文
149 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
mrhu7002 2008-11-28
  • 打赏
  • 举报
回复
[Quote=引用 2 楼 antiking 的回复:]
e.Row.Attributes.Add("ID", RowID);
[/Quote]
这个方法不错,但我建议使用TABLE来写!
gongsun 2008-11-28
  • 打赏
  • 举报
回复
不要用gridview
ggch_x 2008-11-28
  • 打赏
  • 举报
回复
学习了~~
jiang_jiajia10 2008-11-27
  • 打赏
  • 举报
回复
[Quote=引用 2 楼 antiking 的回复:]
e.Row.Attributes.Add("ID", RowID);
[/Quote]
UP
antiking 2008-11-27
  • 打赏
  • 举报
回复
e.Row.Attributes.Add("ID", RowID);
孤独侠客123 2008-11-27
  • 打赏
  • 举报
回复
<asp:Gridview ID="Gridview1" Runat="server" DataSourceID="SqlDataSource1" DataKeyNames="CustomerID" AutoGenerateColumns="False" ShowFooter="True">
<Columns>
 <asp:TemplateField>
  <ItemTemplate>
   <asp:Label ID="CustomerIDLabel" Runat="Server"><%# Eval("CustomerID") %></asp:Label>
  </ItemTemplate>
  <FooterTemplate>
   <asp:TextBox ID="CustomerIDTextBox" Runat="server"></asp:TextBox>
  </FooterTemplate>
 </asp:TemplateField>

 <asp:TemplateField>
  <ItemTemplate>
   <asp:Label ID="CompanyNameLabel" Runat="Server"><%# Eval("CompanyName") %></asp:Label>
  </ItemTemplate>
  <FooterTemplate>
   <asp:TextBox ID="CompanyNameTextBox" Runat="server"></asp:TextBox>
  </FooterTemplate>
 </asp:TemplateField>

 <asp:TemplateField>
  <FooterTemplate>
   <asp:DropDownList ID="ContactTitleDropDownList" Runat="server" DataSourceID="SqlDataSource2" DataTextField="ContactTitle" DataValueField="ContactTitle">
   </asp:DropDownList>
   <asp:SqlDataSource ID="SqlDataSource2" Runat="server" SelectCommand="SELECT DISTINCT [ContactTitle] FROM [Customers]"
ConnectionString="server=localhost;uid=sa;password=xxx;database=northwind">
   </asp:SqlDataSource>

   <asp:Button ID="Button1" Runat="server" Text="Add" OnClick="Button1_Click" />
   <asp:Button ID="CancelButton1" Runat="server" Text="Cancel" OnClick="CancelButton1_Click" />
  </FooterTemplate>

 <ItemTemplate>
  <asp:DropDownList ID="ContactTitleDropDown" SelectedValue=’<%# Bind("ContactTitle") %>’ Runat="Server" DataSourceID="SqlDataSource3" DataTextField="ContactTitle" DataValueField="ContactTitle" ></asp:DropDownList>
  <asp:SqlDataSource ID="SqlDataSource3" Runat="server" SelectCommand="SELECT DISTINCT [ContactTitle] FROM [Customers]"
ConnectionString="server=localhost;uid=sa;password=xxxx;database=northwind" EnableCaching="True">
  </asp:SqlDataSource>
 </ItemTemplate>
 </asp:TemplateField>
</Columns>
</asp:Gridview>

62,046

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术交流专区
javascript云原生 企业社区
社区管理员
  • ASP.NET
  • .Net开发者社区
  • R小R
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

.NET 社区是一个围绕开源 .NET 的开放、热情、创新、包容的技术社区。社区致力于为广大 .NET 爱好者提供一个良好的知识共享、协同互助的 .NET 技术交流环境。我们尊重不同意见,支持健康理性的辩论和互动,反对歧视和攻击。

希望和大家一起共同营造一个活跃、友好的社区氛围。

试试用AI创作助手写篇文章吧