Obtain value from DataGrid to a Session
Can some 1 help me with how to use button column in datagird? my requirement is when u click respective button in the column ..data belongs to that respective button column should be filled with textboxes in below
asap
thnks :)
this is the class i used to load data to the datagird
public 开发者_Python百科void getGrid_viewproblem (GridView a)
{
con = new SqlConnection();
cstring();
data = new SqlDataAdapter("select * from Complaint", con);
build = new SqlCommandBuilder(data);
ds = new DataSet();
data.Fill(ds, "A");
a.DataSource = ds.Tables["A"];
a.DataBind();
}
If you are using AutoGenerateColumns="False" in grid view then Add the Columns
<asp:TemplateField HeaderText="Edit">
<ItemTemplate>
<asp:Button ID="btnEdit" runat="server" Text="Edit" CommandArgument='<%# Bind("ID") %>' CausesValidation="false" CommandName="EditData" Width="55px" />
</ItemTemplate>
</asp:TemplateField>
And then add the OnRowCommand Event.
In OnRowCommand Event check the Condtion
e.CommandName == "EditData"
if the condition satisfies then get the data(PRIMARY KEY) by e.CommandArgument and do as you want
精彩评论