Datagrid does not postback

TheWizardofInt

Junior Contributor
Joined
Dec 31, 1969
Messages
333
Location
Orlando, FL
In using the datagrid, I am unable to get a postback from it

You can click the rows until your fingers bleed and the postback doesn't fire. I find nothing to enable

I am not using AutoGenerate columns. I do dynamically bind the data after a button even has occurred. What I want is for my end user to click a row and to activate the dg.SelectedItemChanged event, which is does not do

The sub procedure for this event DOES use the proper event handler.

Any idea?
 
You have to add an OnItemCommand="SomeEvent" or OnSelectedIndexChanged in the html of the page in the datagrid header tag.

-lp
 
Code:
<DIV id="lblEmails" style="DISPLAY: inline; OVERFLOW: auto; WIDTH: 577px; HEIGHT: 230px"
runat="server" ms_positioning="FlowLayout"><asp:datagrid id="dgInbox" runat="server" Width="572px" BackColor="White" Font-Name="MS Sans Serif"
HorizontalAlign="Center" OnItemCommand="ShowBod" CellPadding="4" AutoGenerateColumns="False" OnEditCommand="ShowMail" Font-Size="2pt" Font-Names="MS Sans Serif">
<SelectedItemStyle BackColor="Yellow"></SelectedItemStyle>
<AlternatingItemStyle BackColor="White"></AlternatingItemStyle>
<HeaderStyle Font-Bold="True" HorizontalAlign="Center" ForeColor="Black" BackColor="#EEEEEE"></HeaderStyle>
	<Columns>
		<mbrsc:RowSelectorColumn SelectionMode="Single" AllowSelectAll="false"></mbrsc:RowSelectorColumn>
		<asp:BoundColumn DataField="Sender" HeaderText="Sender/Recipient">
			<FooterStyle Width="200px"></FooterStyle>
		</asp:BoundColumn>
	<asp:BoundColumn DataField="MailRef" HeaderText="Subject">
			<FooterStyle Width="230px"></FooterStyle>
		</asp:BoundColumn>
		<asp:BoundColumn DataField="Read" HeaderText="Read">
			<FooterStyle Width="30px"></FooterStyle>
		</asp:BoundColumn>
		<asp:BoundColumn DataField="MailDate" HeaderText="Date">
		<FooterStyle Width="100px"></FooterStyle>
	</asp:BoundColumn>
	<asp:BoundColumn Visible="False" DataField="RecId" HeaderText="RecID"></asp:BoundColumn>
	<asp:BoundColumn Visible="False" DataField="Body" HeaderText="RecID"></asp:BoundColumn>
	<asp:EditCommandColumn ButtonType="LinkButton" UpdateText="" CancelText="" EditText="Open"></asp:EditCommandColumn>
	</Columns>
	</asp:datagrid></DIV>

I have tried it without the Div as well - doesn't work

The mbrsc is a Column Counter which I have also tried removing, but which will not then enable the postback

Thanks for your effort on this!
 
Hi,

Try setting the datagrid's AutoPostback property to true.

Then, in the event handler's methods, for (e.g edit click event) check if the "Handles datagrid1.clicked" is present.
 
Back
Top