如何实现点击gridview某一行,显示该行数据到相应的textbox和fileupload进行编辑?? 如何实现点击gridview某一行,显示该行数据到相应的textbox和fileupload进行编辑?? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 autopostback设置为True然后在SelectedIndexChanged事件中,把选中行的数据赋值到相应的TextBox中。 fileupload是只读的,不能显示可以自己做个类似的fileupload的来显示 在哪里把autopostback设置为True ?1楼的能具体点吗?分数全部给你了 <asp:GridView ID="users" runat="server" DataSourceID="SqlDataSource1" AutoGenerateColumns="false" OnRowCommand="custom_romcomand" > <Columns> <asp:ButtonField CommandName="update1" Text="修改" HeaderText="修改"> <ItemStyle Width="60px" HorizontalAlign="Center" /> </asp:ButtonField> </Columns> </asp:GridView>点击修改,可以在custom_romcomand中实现你要的东西 <form id="form1" runat="server"> <div> </div> <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataKeyNames="ID" DataSourceID="AccessDataSource1" BackColor="White" BorderColor="#E7E7FF" BorderStyle="None" BorderWidth="1px" CellPadding="3" GridLines="Horizontal"> <Columns> <asp:BoundField DataField="ID" HeaderText="ID" InsertVisible="False" ReadOnly="True" SortExpression="ID" /> <asp:BoundField DataField="product" HeaderText="product" SortExpression="product" /> <asp:BoundField DataField="quantity" HeaderText="quantity" SortExpression="quantity" /> <asp:BoundField DataField="classify" HeaderText="classify" SortExpression="classify" /> <asp:BoundField DataField="typeofworkName" HeaderText="typeofworkName" SortExpression="typeofworkName" /> <asp:BoundField DataField="plant" HeaderText="plant" SortExpression="plant" /> <asp:BoundField DataField="group" HeaderText="group" SortExpression="group" /> <asp:BoundField DataField="date" HeaderText="date" SortExpression="date" /> <asp:BoundField DataField="companyExperiment" HeaderText="companyExperiment" SortExpression="companyExperiment" /> <asp:BoundField DataField="employee" HeaderText="employee" SortExpression="employee" /> <asp:BoundField DataField="classifyName" HeaderText="classifyName" SortExpression="classifyName" /> <asp:BoundField DataField="childClassifyName" HeaderText="childClassifyName" SortExpression="childClassifyName" /> <asp:BoundField DataField="leveldiff" HeaderText="leveldiff" SortExpression="leveldiff" /> <asp:TemplateField> <ItemTemplate> <asp:Button ID="Button1" runat="server" Text="修改" CommandArgument='<%# Eval("ID") %>' OnCommand="Button1_Command" /> </ItemTemplate> </asp:TemplateField> </Columns> <FooterStyle BackColor="#B5C7DE" ForeColor="#4A3C8C" /> <RowStyle BackColor="#E7E7FF" ForeColor="#4A3C8C" /> <PagerStyle BackColor="#E7E7FF" ForeColor="#4A3C8C" HorizontalAlign="Right" /> <SelectedRowStyle BackColor="#738A9C" Font-Bold="True" ForeColor="#F7F7F7" /> <HeaderStyle BackColor="#4A3C8C" Font-Bold="True" ForeColor="#F7F7F7" /> <AlternatingRowStyle BackColor="#F7F7F7" /> </asp:GridView> <asp:AccessDataSource ID="AccessDataSource1" runat="server" DataFile="~/App_Data/dbwz.mdb" SelectCommand="SELECT * FROM [工序表]"></asp:AccessDataSource> <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox> </form> protected void Button1_Command(object sender, CommandEventArgs e) { OleDbConnection conn = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=|DataDirectory|\\dbwz.mdb;Persist Security Info=True"); string strSql = "select * from 工序表 where id=" + e.CommandArgument + ""; OleDbDataAdapter da = new OleDbDataAdapter(strSql, conn); DataTable dt = new DataTable(); da.Fill(dt); TextBox1.Text += dt.Rows[0][0].ToString(); TextBox1.Text += dt.Rows[0][1].ToString(); TextBox1.Text += dt.Rows[0][2].ToString(); TextBox1.Text += dt.Rows[0][3].ToString(); TextBox1.Text += dt.Rows[0][4].ToString(); }代码代码是我用来测试的,并不严谨,有错误之处还望达人纠正!基本可以实现楼住的功能,方便快捷 参考:http://blog.csdn.net/insus/archive/2008/02/27/2123970.aspx把GridView点击那行的记录的主键取出来了,什么都好办了. checkboxlist与label(其它的控件也行)自定义组合控件 cache丢失 已经记录的原因,但是不知道怎么引起,大家帮忙看看 asp.net正则表达式匹配字符串 web treeview控件如何实现移动节点?? 请知道iBatis的进来下 如何将txt文件里面的内容消除(50分哦~~~~~~) VS2003中的Datagrid,如何响应键盘方向键? 我不行了,快崩溃了,搞net2.0的兄弟来帮我看看 如何更改vs.net使用的.framework的版本 在ASP.NET上用VB编程 如何使用其他页面控件上的内容? 睡前问一个问题 Datagrid根据内容改变单元格颜色问题?
可以自己做个类似的fileupload的来显示
1楼的能具体点吗?分数全部给你了
OnRowCommand="custom_romcomand" >
<Columns>
<asp:ButtonField CommandName="update1" Text="修改" HeaderText="修改">
<ItemStyle Width="60px" HorizontalAlign="Center" />
</asp:ButtonField>
</Columns>
</asp:GridView>
点击修改,可以在custom_romcomand中实现你要的东西
<div>
</div>
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataKeyNames="ID" DataSourceID="AccessDataSource1" BackColor="White" BorderColor="#E7E7FF" BorderStyle="None" BorderWidth="1px" CellPadding="3" GridLines="Horizontal">
<Columns>
<asp:BoundField DataField="ID" HeaderText="ID" InsertVisible="False" ReadOnly="True"
SortExpression="ID" />
<asp:BoundField DataField="product" HeaderText="product" SortExpression="product" />
<asp:BoundField DataField="quantity" HeaderText="quantity" SortExpression="quantity" />
<asp:BoundField DataField="classify" HeaderText="classify" SortExpression="classify" />
<asp:BoundField DataField="typeofworkName" HeaderText="typeofworkName" SortExpression="typeofworkName" />
<asp:BoundField DataField="plant" HeaderText="plant" SortExpression="plant" />
<asp:BoundField DataField="group" HeaderText="group" SortExpression="group" />
<asp:BoundField DataField="date" HeaderText="date" SortExpression="date" />
<asp:BoundField DataField="companyExperiment" HeaderText="companyExperiment" SortExpression="companyExperiment" />
<asp:BoundField DataField="employee" HeaderText="employee" SortExpression="employee" />
<asp:BoundField DataField="classifyName" HeaderText="classifyName" SortExpression="classifyName" />
<asp:BoundField DataField="childClassifyName" HeaderText="childClassifyName" SortExpression="childClassifyName" />
<asp:BoundField DataField="leveldiff" HeaderText="leveldiff" SortExpression="leveldiff" />
<asp:TemplateField>
<ItemTemplate>
<asp:Button ID="Button1" runat="server" Text="修改" CommandArgument='<%# Eval("ID") %>' OnCommand="Button1_Command" />
</ItemTemplate>
</asp:TemplateField>
</Columns>
<FooterStyle BackColor="#B5C7DE" ForeColor="#4A3C8C" />
<RowStyle BackColor="#E7E7FF" ForeColor="#4A3C8C" />
<PagerStyle BackColor="#E7E7FF" ForeColor="#4A3C8C" HorizontalAlign="Right" />
<SelectedRowStyle BackColor="#738A9C" Font-Bold="True" ForeColor="#F7F7F7" />
<HeaderStyle BackColor="#4A3C8C" Font-Bold="True" ForeColor="#F7F7F7" />
<AlternatingRowStyle BackColor="#F7F7F7" />
</asp:GridView>
<asp:AccessDataSource ID="AccessDataSource1" runat="server" DataFile="~/App_Data/dbwz.mdb"
SelectCommand="SELECT * FROM [工序表]"></asp:AccessDataSource>
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
</form>
protected void Button1_Command(object sender, CommandEventArgs e)
{
OleDbConnection conn = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=|DataDirectory|\\dbwz.mdb;Persist Security Info=True");
string strSql = "select * from 工序表 where id=" + e.CommandArgument + "";
OleDbDataAdapter da = new OleDbDataAdapter(strSql, conn);
DataTable dt = new DataTable();
da.Fill(dt);
TextBox1.Text += dt.Rows[0][0].ToString();
TextBox1.Text += dt.Rows[0][1].ToString();
TextBox1.Text += dt.Rows[0][2].ToString();
TextBox1.Text += dt.Rows[0][3].ToString();
TextBox1.Text += dt.Rows[0][4].ToString(); }
代码代码是我用来测试的,并不严谨,有错误之处还望达人纠正!基本可以实现楼住的功能,方便快捷
http://blog.csdn.net/insus/archive/2008/02/27/2123970.aspx把GridView点击那行的记录的主键取出来了,什么都好办了.