web user control with grid having command handler

M

Michal Januszczyk

Is it possible to create a control that would have a data
grid embedded, that would have some button columns
causing some action ?

When my grid does not have a button column all works
fine. But when having added it , the browser when loads
the form with the embedded control displays some
javascript error (object required or sth..)

The code for my control is pretty simple:

....

private void Page_Load(object sender, System.EventArgs e)
{
DataSet dsFolderContens = new DataSet();;
dsFolderContens.Tables.Add();
dsFolderContens.Tables[0].Columns.Add("intMailID", typeof
(int));
dsFolderContens.Tables[0].Columns.Add("vstrTitle", typeof
(string));
dsFolderContens.Tables[0].Rows.Add(new object[]
{4,"title"});
dgrFolderContents.DataSource = dsFolderContens;
dgrFolderContents.DataBind();
}

and the control itself:
<form id="form1" runat="server">
<asp:DataGrid ID="dgrFolderContents" Runat="server"
AutoGenerateColumns="False"
OnItemCommand="CommandHandler" DataKeyField="intMailID">
<Columns>
<asp:ButtonColumn Runat="server"
HeaderText="Title"
DataTextField="vstrTitle"
CommandName="DisplaySelectedMail">
</asp:ButtonColumn>
</Columns>
</asp:DataGrid>
</form>


The very same code, when being put on web form (without
being wrapped by control) works fine..

Thanks for any suggestions
Michal Januszczyk
 
M

michal januszczyk

I've forgotten to enclose in my previous post
commandHandler method.
It is also simple:

protected void CommandHandler(Object sender,
DataGridCommandEventArgs args)
{
if(args.CommandName =="DisplaySelectedMail")
{
int a=0;
}
}

Can anyone help?
Michal
 
M

Microsoft

Please Provide the exact error message.We are doing our entire project with
Datagrid with button controls inside.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,076
Messages
2,570,565
Members
47,201
Latest member
IvyTeeter

Latest Threads

Top