net得到gridview在文本框中的選定值。 我想從gridview中選擇值到文本框中,我已經使用sqlserever數據庫來顯示數據到gridview。 沒有其他的鏈接對我有幫助me.plz幫助我。如何使用MVC(aspx).net
我BranchManage.aspx頁的ASPX GridView的是:
<asp:GridView ID="GridView1" runat="server" CellPadding="4" ForeColor="#333333"
GridLines="None" AutoGenerateColumns="False" DataSourceID="LinqDataSource_Branch">
<Columns>
<asp:CommandField ShowSelectButton="True" />
<asp:BoundField DataField="BranchName" HeaderText="BranchName" ReadOnly="True"
SortExpression="BranchName" />
<asp:BoundField DataField="CreateDate" HeaderText="CreateDate" ReadOnly="True"
SortExpression="CreateDate" />
</Columns>
</asp:GridView>
<asp:LinqDataSource ID="LinqDataSource_Branch" runat="server"
ContextTypeName="jemex.db.JemexDataContext" EntityTypeName=""
Select="new (BranchName, CreateDate)" TableName="Branches">
</asp:LinqDataSource>
-----這是我的LoginController.cs部分代碼:
public ActionResult BranchManage(string submitButton, string branchname)
{
ViewBag.UserName = Session["username"];
if (Session["type"].ToString() == "Admin")
{
switch (submitButton)
{
case "Create Account":
return (Create_BranchAccount(branchname));
case "Update Account":
return (Update_BranchAccount());
case "Clear":
return (ClearBranch());
default:
return View();
}
}
else
{
return View("Login");
}
}
public ActionResult Create_BranchAccount(string branchname)
{
//DB.Execute_Qury("INSERT INTO Branches(BranchName,CreateDate,IsDeleted) VALUES (" +
branchname + "," + System.DateTime.Now + ",False)");
db1.R_Insert_Branch(branchname, System.DateTime.Now);
return View("BranchManage");
}
public ActionResult Update_BranchAccount()
{
SqlConnection con = new SqlConnection("Data Source=aaa-pc;Initial Catalog=logicnetclub_jemex;Integrated Security=True");
string strSQL = "Select * from Branches";
SqlDataAdapter dt = new SqlDataAdapter(strSQL, con);
DataSet ds = new DataSet();
dt.Fill(ds, "UserDetail");
con.Close();
GridView1.DataSource = ds;
GridView1.DataBind();
return View(ViewModel);
}
這裏在update_BranchAccount,如何我可以獲取gridview數據源嗎?
@ dav-i請不要盲目地從標題中刪除標籤。 – Danack