开发者

Accessing gridview from a non GridView event

I have a button outside a gridview called "UpdateAll", i need to be able to click on such button and find an item template "DropDownList" and update the database with that value for each record, I am not sure how to go about this any ideas?

  public void UpdateAll_Click(object sender, EventArgs e)
{

}

Now I know I can access the drop down in the GridView_RowCommand something like this

  GridViewRow row = (GridViewRow)(((Button)e.CommandSource).NamingContainer);
        Myddl = row.FindControl("Quantity") as DropDownList;

But i am not sure how to do that from an outside event that is开发者_如何学C not GridView related, I can not do the one above because it accesses the e.CommandSource.

Please help.


You can do something like this;

for(int rowIndex =0; rowIndex<gv.rows.count; rowIndex++)
{
  Myddl = gv.rows[rowIndex].FindControl("Quantity") as DropDownList;

}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜