|
code
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Gridview QuestionsI've got two questions on how to do things in the new GridView. I'm used to
the DataGrid in ASP 1.1, so I need the equavalent in ASP 2.0 Gridview. 1.) What is the equavalent for Item Command event in GridView? I thought it would be RowCommand, but I can't get that event to fire with a check box field that I drag/drop in a template column in the ItemTemplate. 2.) For a Templated column, like a check box above, where do I tell it the data field to bind from the data source? There is not a Template DataField property to set to the database field name as in a bound field. -- Chris Davoli hi Chris, Checkbox control does not fire a command Event so you are out of
luck here. Nothing will be fired in the RowCommand method. Your alternative is to wire the checkedchanged event declaratively on the checkbox control itself like : <asp:CheckBox ID="CheckBox1" runat="server" OnCheckedChanged="CheckBox1_CheckedChanged" /> the method it is wired to : protected void CheckBox1_CheckedChanged(object sender, EventArgs e) { } As for your second question, do it as you did in asp.net 1.1. Add the checkbox to the itemtemplate, and call a method in your codebehind that returns true or false, based on the value of the datafield. Alternatively, following is a proper example on how to include a checkbox in a datagrid control using custom templates, the same style will apply to the gridview as well. Small minor changes on how to hookup the custom checkbox template, but nothing you cant find answers to on google or postback here with problems. http://support.microsoft.com/kb/306227/ Regards, Alessandro Zifiglio http://www.AsyncUI.net Show quoteHide quote "Chris Davoli" <ChrisDav***@discussions.microsoft.com> ha scritto nel messaggio news:F48AFFA9-CEE3-4FD8-BE02-6A9F0C2D074B@microsoft.com... > I've got two questions on how to do things in the new GridView. I'm used > to > the DataGrid in ASP 1.1, so I need the equavalent in ASP 2.0 Gridview. > > 1.) What is the equavalent for Item Command event in GridView? I thought > it > would be RowCommand, but I can't get that event to fire with a check box > field that I drag/drop in a template column in the ItemTemplate. > > 2.) For a Templated column, like a check box above, where do I tell it the > data field to bind from the data source? There is not a Template DataField > property to set to the database field name as in a bound field. > > -- > Chris Davoli >
Dynamic ImageButton inside GridView ASP .NET
dynamic image? store and retrieve properties values? resizable web control? Create A 3-Day Window Between 2 Calendars Hiding columns in GridView control label control Redirecting to another page after a specified time User Control Renders on Separate Line Integration with office Recommended way to add child controls in CreateChildControls Problem with capturing enter key in TextBox within UserControl |
|||||||||||||||||||||||