填充和编辑GridView [英] Populating and Editing GridViews

查看:64
本文介绍了填充和编辑GridView的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





我不知道在哪里放这个话题,所以如果它在错误的地方我道歉。



我是VB.NET和ASP.NET的新手,我正在尝试用可编辑的GridView创建一个网站。



我正在使用Visual Studio 2005并且已经进入了我需要GridView的阶段。

我已经用10列ProjectID,描述,MON,TUE,WED,THUR,FRI,SAT填充了GridView来自SQL数据源和存储过程的SUN和Total,并将其设置为自动生成编辑按钮。



GridView自动将所有内容设置为标签,直到您单击编辑,然后将所有内容更改为TextBox。



当我单击编辑时,我希望GridView将其中一列(ProjectID)更改为填充的DropDownList使用SQL Select查询中的值,当您在此列表中选择某些内容时,另一列(描述)需要自动更改基于ProjectID列内容的值。



如果选择0,则ProjectID列需要能够将Description列设置为Miscellaneous,Holiday如果选择1并且选择2则选择Sick等。



 ProjectID描述MON TUE WED THU FRI SAT SUN总计
0其他8 8 8 8 4 0 0 36
1假期0 0 0 0 0 8 8 16
2生病0 0 0 0 4 0 0 4



除此之外,我需要说明只有在选择杂项时才能手动编辑,但需要根据ProjectID的值自动更新。



I已经搜索了几千个网站,我可以弄清楚如何在编辑时将列更改为DropDownList,但这就是它。



任何帮助都会非常感谢!



提前致谢:-D

解决方案

你好



你需要将edittamplate属性用于gridview。

使用以下链接



http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.templatefield.edititemtemplate.aspx [ ^ ]

Hi,

I wasn't sure where to put this topic, so if it's in the wrong place I apologise.

I'm new to developing in VB.NET and ASP.NET and I am trying to make a website with an editable GridView.

I am using Visual Studio 2005 and have got to the stage where I need a GridView.
I have populated the GridView with 10 columns ProjectID, Description, MON, TUE, WED, THUR, FRI, SAT, SUN, and Total from a SQL Data Source and Stored Procedure and have set it to automatically generate an edit button.

The GridView automatically sets everything as a Label until you click Edit and it then changes everything to a TextBox.

When I click Edit I want the GridView to change one of the columns (ProjectID) to a DropDownList that is populated with values from a SQL Select query, and when you select something in this list, another column (Description) needs to automatically change to a value based on the content of the ProjectID column.

The ProjectID column would need to be able to set the Description column to be Miscellaneous if 0 is selected, Holiday if 1 is selected and Sick if 2 is selected etc..

ProjectID   Description   MON   TUE   WED   THU   FRI   SAT   SUN   Total
0           Miscellaneous 8     8     8     8     4     0     0     36
1           Holiday       0     0     0     0     0     8     8     16
2           Sick          0     0     0     0     4     0     0     4


Along with this I need Description to only be manually editable if Miscellaneous is selected, but it needs to update automatically depending on the value of ProjectID.

I've searched through what seems like thousands of websites and I can figure out how to change a column to a DropDownList when being edited but that's about it.

Any help would be greatly appreciated!

Thanks in advance. :-D

解决方案

Hello

U need to use edittamplate property into gridview.
Use the below link

http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.templatefield.edititemtemplate.aspx[^]


这篇关于填充和编辑GridView的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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